The present document includes the analytical steps implemented to characterize and explore the antecedents of sleep patterns in a sample of older adolescents with (N = 47; 31 girls) and without (N = 46; 28 girls) DSM-5 insomnia.
The data processing pipeline is depicted at this page, whereas the first part of data analysis (data preparation, psychometrics, and descriptives) is depicted at this page. The latter script resulted in the following long-form ema and wide-form demos datasets:
# removing all objets from the workspace
rm(list=ls())
# loading datasets exported at the end of the first Data Analysis script
load("emaFINAL.RData")
load("demosFINAL.RData")
# setting system time zone to GMT (for consistent temporal synchronization)
Sys.setenv(tz="GMT")
Here, we use generalized linear mixed-effects regression (GLMER) models to examine the direct and bidirectional relationships between sleep and psychological distress. In the following models, s.archit, s.timing, s.variab, and s.auton variables measured at day i are predicted by the predictors selected in step 1 in addition to the diary ratings (stress, worry, mood, PsyDist, and fs) measured at day i (M5), and diary ratings measured at day i+1 (M6), in order to evaluate the direct and bidirectional relationship between sleep and psychological distress. Finally, the interaction between diary ratings and insomnia is included in model M7.
Finally, we generate the final outputs reported in the main paper.
For each step and each outcome variable, models are specified by using alternative distribution families based on the nature of the outcome, inspected to evaluate model fit, compared in terms of likelihood and strength of evidence, and inspected to check the results of the selected model.
Note that all level-1 continuous predictors are centered to the individual mean (mean-centered, mc), whereas all level-2 continuous predictors are centered to the grand average (grand-mean-centered, gmc).
Finally, several robustness checks are performed to account for the arbitrariness of data processing and analytical choices, including (1) the consideration of insomnia.group instead of the insomnia variable, (2) the inclusion of covid19 as a further covariate, (3) the exclusion of participants with extreme missing data (marked with majMiss = 1), (4) the exclusion of the TotalSteps1000 variable from the analyses, (5) the use of alternative family distributions for those variables not showing optimal fit, and (6) the exclusion of diary ratings entered on the following day (marked with lateResp = 1).
The following R packages and functions are used.
# required packages
packages <- c("dplyr","Rmisc","lme4","ordinal","sjPlot","ggplot2","car","knitr","MuMIn","knitr","XML","sjPlot","reshape2")
# generate packages references
knitr::write_bib(c(.packages(), packages),"packagesAn.bib")
# # run to install missing packages
# xfun::pkg_attach2(packages, message = FALSE); rm(list=ls())
# loading mainly used packages
library(lme4); library(ordinal); library(reshape2); library(MuMIn); library(sjPlot); library(ggplot2); library(Rmisc)
glmerAn (from https://github.com/Luca-Menghini/LuMenPsy.Rfunctions )
#' @title Generalized linear (mixed-effects) regression analysis
#' @param modelType = type of model: GLM, mixed-effects (GLMER), or cumulative link mixedm odel (CLMM)
#' @param long = long-form dataset (data.frame) considered if modelType = GLMER or CLMM
#' @param wide = wide-form dataset (data.frame)
#' @param resp = name of the response variable (character)
#' @param fix.eff = character vector of names of the predictor(s)
#' @param cluster.ID = name of the cluster variable considered if modelType = GLMER or CLMM (default: "ID")
#' @param timeVar = name of the variable indexing time, considered if modelType = GLMER (defult: "ActivityDate")
#' @param REML = argument from the lme4::lmer() function, see ?lmer
#' @param ran.eff = character string indicating the random effect by using the lme4 syntax (defult: "(1|ID)")
#' @param family = character string indicating the name of the GLM(ER) family to be used in the models (default: "normal")
#' @param link =character string indicating the name of the GLM(ER) link function to be used in the models (default: "identity")
#' @param nAGQ = argument from the lme4::glmer() function, see ?glmer
#' @param mc.predictors = character vector of names of the predictors to be mean-centered
#' @param gmc.predictors = character vector of names of the predictors to be grand-mean-centered
#' @param outputs = character vector of the desired otucomes: "fit" for model diagnostics, "mComp" for model comparison, "coeff" for the coefficient table, "plotEff" for the effect plot(s), and "key.res" for the key results
#' @param coeff.models = name of the predictor(s) whose corresponding model(s) should be considered for the "coeff" output
#' @param transform = argument from sjPlot::tab_model(), see ?tab_model
#' @param coeff.models = model(s) to be considered for the "coeff" output
#' @param plot.model = name of the predictor(s) whose model(s) should be considered for the "plotEff" output
#' @param plot.pred = name of the predictor(s) to be plotted
#' @param show.data = argument from sjPlot::plot_model(), see ?plot_model
#' @param dot.size = argument from sjPlot::plot_model(), see ?plot_model
#' @param dodge = argument from sjPlot::plot_model(), see ?plot_model
#' @param dot.size = argument from sjPlot::plot_model(), see ?plot_model
#' @param ci.lv = argument from sjPlot::plot_model(), see ?plot_model
#' @param y.lim = numeric vector of length 2 indicating the limits of the y-axis
#' @param return.plot = booean. Should the plot be returned by the function? (default: FALSE)
#' @param key.model = name of the predictor(s) whose model(s) should be considered for the "key.res" output
#' @param key.predictor = name of the predictor to be considered by the "key.res" output
#' @param digits = number of digits for all numeric ouputs
#' @param messages = boolean indicating whether a message should be printed for each operation (defult: FALSE)
glmerAn <- function(modelType=c("GLM","GLMER"),long,wide,resp,fix.eff,cluster.ID="ID",timeVar="ActivityDate",REML=FALSE,
ran.eff="(1|ID)",family="normal",link="identity",nAGQ=1,mc.predictors=NA,gmc.predictors=NA,
outputs=c("fit","mComp","coeff","plotEff","key.results"),coeff.models=NA,transform=NULL,
plot.model=NA,plot.pred="all",show.data=FALSE,dot.size=1,dodge=0,ci.lv=.95,y.lim=NA,return.plot=FALSE,
key.model=NA,key.predictor=NA,digits=3,messages=TRUE){
if(messages==TRUE){ cat("Running",modelType,"analysis of",resp,"...") }
# data preparation ..................................................................................................................
if(messages==TRUE){ cat("\n\nPreparing data...") }
# participants' ID recoding as factor
colnames(long)[which(colnames(long)==cluster.ID)] <- colnames(wide)[which(colnames(wide)==cluster.ID)] <- "ID"
long$ID <- as.factor(as.character(long$ID))
wide$ID <- as.factor(as.character(wide$ID))
wide <- wide[order(wide$ID),] # sorting wide by ID
colnames(long)[which(colnames(long)==timeVar)] <- "time" # time variable
long <- long[order(long$ID,long$time),] # sorting long by ID and time
if(nlevels(long$ID)!=nlevels(wide$ID)){ stop(message="Error: different No. of participants in long and wide datasets") }
# listwise deletion
if(modelType%in%c("GLMER","CLMM")){ memory <- long
for(Var in c(resp,fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)])){ colnames(long)[which(colnames(long)==Var)] <- "Var"
long <- long[!is.na(long$Var),] # removing obs. with missing response in any resp or fix.eff variable
colnames(long)[which(colnames(long)=="Var")] <- Var }
long$ID <- as.factor(as.character(long$ID))
wide <- wide[wide$ID%in%levels(long$ID),] # excluding wide IDs not included in long IDs
if(messages==TRUE){ cat("\n - Excluding",nrow(memory)-nrow(long),"incomplete observations (",
round(100*(nrow(memory)-nrow(long))/nrow(memory),1),
"% ) in the response var. or in any of the predictors,\n and",
nlevels(memory$ID)-nlevels(long$ID),"participants with no complete variables") }
} else { memory <- wide
for(Var in c(resp,fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)])){ colnames(wide)[which(colnames(wide)==Var)] <- "Var"
wide <- wide[!is.na(wide$Var),]
colnames(wide)[which(colnames(wide)=="Var")] <- Var }
if(messages==TRUE){ cat("\n - Excluding",nrow(memory)-nrow(wide),"participants with no complete variables") }}
# mean-centering predictors
if(!is.na(gmc.predictors[1])){ if(messages==TRUE){ cat("\n - Grand-mean-centering",paste(gmc.predictors,collapse=" , ")) }
for(Var in gmc.predictors){ colnames(wide)[which(colnames(wide)==Var)] <- "Var"
wide$Var.gmc <- wide$Var - mean(wide$Var,na.rm=TRUE) # computing gmc values
colnames(wide) <- gsub("Var",Var,colnames(wide))
long <- plyr::join(long,wide[,c("ID",paste(Var,"gmc",sep="."))],type="left",by="ID") # joining gmc to long dataset
fix.eff <- gsub(Var,paste(Var,"gmc",sep="."),fix.eff) }} # updating labels in fix.eff (from Var to Var.gmc)
if(!is.na(mc.predictors[1])){ if(messages==TRUE){ cat("\n - Mean-centering",paste(mc.predictors,collapse=" , ")) }
suppressMessages(suppressWarnings(require(Rmisc)))
for(Var in mc.predictors){ colnames(long)[which(colnames(long)==Var)] <- "Var"
wide$Var.cm <- suppressWarnings(summarySE(long,measurevar="Var",groupvars="ID",na.rm=TRUE)[,3]) # cluster means
long <- plyr::join(long,wide[,c("ID","Var.cm")],type="left",by="ID") # joining cm to long dataset
long$Var.mc <- long$Var - long$Var.cm # computing mc values
colnames(long) <- gsub("Var",Var,colnames(long))
fix.eff <- gsub(Var,paste(Var,"mc",sep="."),fix.eff) }} # updating labels in fix.eff (from Var to Var.mc)
long <- long[,!duplicated(colnames(long))] # removing duplicated columns (don't know why)
# modeling .........................................................................................................................
# creating model formulas
formulas <- character()
if(modelType=="GLM"){ ran.eff <- "1" }
null.f <- paste(resp,"~",ran.eff) # creating null model formula
for(i in 1:length(fix.eff)){ # creating other formulas
if(i==1){ formulas[i] <- paste(resp,"~",fix.eff[1]) } else { formulas[i] <- paste(formulas[i-1],"+",fix.eff[i]) }}
if(modelType%in%c("GLMER","CLMM")){ if(!is.na(ran.eff)){ formulas <- paste(formulas,"+",ran.eff)
if(substr(ran.eff,2,2)!="1"){ ranSlope <- paste(fix.eff[which(grepl(ran.eff,fix.eff))])[1]
null.f <- gsub(ranSlope,"1",null.f) # removing random slope from models without the related predictor
for(i in 1:length(formulas)){
if(!(grepl(ranSlope,gsub(paste(ranSlope,"[|]",sep=""),"",formulas[i])))){
formulas[i] <- gsub(paste(ranSlope,"[|]",sep=""),"1|",formulas[i]) }}}
} else { stop(message="Error: GLMER model type without ran.eff specification") }}
if(messages==TRUE){ cat("\n\nModel specification:\n - model M0 (null):",null.f)
for(i in 1:length(formulas)){ cat("\n - model M",i,": ",formulas[i],sep="")}}
# fitting models
models <- list()
if(modelType=="GLM"){ if(messages==TRUE){ cat("\n\nFitting GLM models of",resp,"on",nrow(wide),"participants \n using the",
family,"family with the",link,"link function...") }
if(family=="normal" & link=="identity"){ null.m <- lm(as.formula(null.f),data=wide) # normal family
for(i in 1:length(formulas)){ models[[i]] <- lm(formula=as.formula(formulas[i]),data=wide) }
} else if (family=="gamma") { null.m <- glm(as.formula(null.f),data=wide,family=Gamma(link=link),nAGQ=nAGQ) # gamma family
for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=Gamma(link=link)) }
} else if(family=="normal" & link!="identity"){
null.m <- glm(as.formula(null.f),data=wide,family=gaussian(link=link)) # normal with other link functions
for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=gaussian(link=link)) }
} else if(family=="binomial"){
null.m <- glm(as.formula(null.f),data=wide,family=binomial(link=link)) # logistic regression
for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=binomial(link=link))}
} else { stop(message="Error: only normal, gamma, and binomial family are allowed,
with identity, inverse, and log link functions") }
} else if(modelType=="GLMER"){ suppressMessages(suppressWarnings(require(lme4)))
if(messages==TRUE){ cat("\n\nFitting",modelType,"models of",resp,"on",nrow(long),"observations from",
nlevels(as.factor(as.character(long$ID))),"participants \n using the",family,
"family with the",link,"link function using",ifelse(REML==FALSE,"ML","REML"),"estimator...") }
if(family=="normal" & link=="identity"){ null.m <- lmer(as.formula(null.f),data=long,REML=REML) # normal identity
for(i in 1:length(formulas)){ models[[i]] <- lmer(formula=as.formula(formulas[i]),data=long,REML=REML) }
} else if (family=="gamma") { null.m <- glmer(as.formula(null.f),data=long,family=Gamma(link=link),nAGQ=nAGQ) # gamma
for(i in 1:length(formulas)){ models[[i]]<-glmer(formula=as.formula(formulas[i]),data=long,family=Gamma(link=link),nAGQ=nAGQ) }
} else if(family=="normal" & link!="identity"){
null.m <- glmer(as.formula(null.f),data=long,family=gaussian(link=link),nAGQ=nAGQ) # normal with other links
for(i in 1:length(formulas)){ models[[i]] <- glmer(formula=as.formula(formulas[i]),data=long,
family=gaussian(link=link),nAGQ=nAGQ) }
} else if(family=="binomial"){ null.m <- glmer(as.formula(null.f),data=long,family=binomial(link=link),nAGQ=nAGQ) # logistic
for(i in 1:length(formulas)){ models[[i]] <- glmer(formula=as.formula(formulas[i]),data=long,
family=binomial(link=link),nAGQ=nAGQ)}
} else { stop(message="Error: only normal, logistic, and gamma family are allowed,
with identity, inverse, and log link functions") }
} else if(modelType=="CLMM"){ suppressMessages(suppressWarnings(require(ordinal))) # cumulative link mixed models
if(messages==TRUE){ cat("\n\nFitting",modelType,"models of",resp,"on",nrow(long),"observations from",
nlevels(as.factor(as.character(long$ID))),"participants \n using Cumulative Link Mixed Models") }
long[,resp] <- factor(long[,resp],ordered=TRUE) # response variable as ordered factor
null.m <- suppressWarnings(clmm(as.formula(gsub("~","~ 1 +",null.f)),data=long)) # suppress formula warning (bugged)
for(i in 1:length(formulas)){ models[[i]] <- suppressWarnings(clmm(formula=as.formula(formulas[i]),data=long,nAGQ=nAGQ)) }
} else { stop(message="Error: modelType can only be 'GLM', 'GLMER', or 'CLMM'") }
# outputs..........................................................................................................................
if(messages==TRUE){ cat("\n\nGenerating models outputs...") }
# model diagnostics
if("fit"%in%outputs & modelType!="CLMM"){ if(messages==TRUE){ cat("\n\n - Plotting diagnostics of the most complex model:") }
suppressMessages(suppressWarnings(require(sjPlot))); suppressMessages(suppressWarnings(require(ggplot2)))
fit <- models[[length(models)]] # most complex model
if(modelType=="GLMER"){ dat <- long } else { dat <- wide } # fitted dataset
plots <- list()
if(family=="normal" & link=="identity"){ p <- plot_model(fit,type="diag",dot.size=dot.size) # LM(ER) diagnostics (normal)
if(modelType=="GLMER"){ p[[2]] <- p[[2]]$ID }
suppressMessages(plot_grid(p,tags=TRUE,margin=c(0,0,0,0)))
} else { if(family=="binomial"){ # logistic regression
dat$logit <- log(predict(fit,type="response")/(1-predict(fit,type="response"))) # computing logit
for(Var in fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)]){ # plotting logit by each continuous predictor
if(class(dat[,Var])=="numeric"){ plots[[length(plots)+1]] <- ggplot(dat,aes_string(x=Var,y="logit")) +
geom_point(size=dot.size) + suppressMessages(stat_smooth(method="loess")) + ggtitle("Logit by",Var) }}
} else { plots[[length(plots)+1]] <- ggplot(data.frame(residuals=residuals(fit,type="deviance")), # deviance residuals QQ plot
aes(sample=residuals)) + stat_qq(size=dot.size) + stat_qq_line() +
labs(x="Theoretical qualtiles (normal distr.)",y="Sample quantiles") + ggtitle("Deviance Residuals' normal QQ plot")
plots[[length(plots)+1]] <- ggplot(fortify.merMod(fit), aes(.fitted, resid(fit,type="deviance"))) + geom_point() +
suppressMessages(stat_smooth(method="loess"))+geom_hline(yintercept=0, col="red", linetype="dashed") +
labs(x="Fitted values",y="Residuals") + ggtitle("Deviance residuals vs. fitted values") }
p <- plot_model(fit,type="diag",dot.size=dot.size) # random effects with GLMER
if(modelType=="GLMER"){ p <- p$ID }
plots[[length(plots)+1]] <- p + ggtitle("Random effects' normal QQ plot") }
if(family!="binomial"){ type <- ifelse(family=="gamma","deviance","pearson") # deviance residuals with gamma
for(Var in fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)]){ # homoscedasticity: residuals by levels of categorical pred.
if(class(dat[,Var])=="factor"){ Dat <- cbind(dat,residuals=resid(fit,type=type),Var=dat[,Var],Resp=dat[,resp])
plots[[length(plots)+1]] <- ggplot(Dat,aes_string(x="Var",y="residuals")) +
ggtitle(paste(type,"residuals by",Var,"\n mean =",paste(round(with(Dat, tapply(Resp, Var, mean)),1),collapse=", "),
", SD =",paste(round(with(Dat, tapply(Resp, Var, sd)),1),collapse=", "))) + xlab(Var) +
geom_point(size=dot.size,position=position_jitter(),color="gray") + geom_violin(alpha=0.3) }}}
suppressMessages(plot_grid(plots,tags=TRUE,margin=rep(0,4)))
cat("\n Printing Variance Inflation Factors (VIF):\n")
suppressMessages(suppressWarnings(require(car))) # variance inflation factors
print(vif(fit)) }
# model comparison - likelihood ratio test & Akaike weight
if("mComp"%in%outputs | "key.results"%in%outputs){
if(messages==TRUE){ cat("\n\n - Running likelihood ratio test:") } # likelihood ratio test
suppressMessages(suppressWarnings(require(knitr))); suppressMessages(suppressWarnings(require(MuMIn)))
if(modelType=="CLMM"){ lrt <- as.data.frame(ordinal:::anova.clm(null.m,models[[1]])) # use anova.clm() to avoid env. issue
} else { lrt <- as.data.frame(suppressMessages(anova(null.m,models[[1]]))) }
for(i in 1:(length(models)-1)){ if(length(models)>=(i+1)){
if(modelType=="CLMM"){ lrt <- rbind(lrt,as.data.frame(ordinal:::anova.clm(models[[i]],models[[i+1]]))[2,])
} else { lrt <- rbind(lrt,as.data.frame(suppressMessages(anova(models[[i]],models[[i+1]])))[2,]) }}}
rownames(lrt) <- c("Null model",fix.eff)
for(i in nrow(lrt):2){ if(lrt[i,ncol(lrt)] < .05){ if(messages==TRUE){ cat("\n Selected model:",rownames(lrt)[i]) }
break }}
if("mComp"%in%outputs){ print(kable(round(lrt,digits))) }
AICs <- lrt[1:2,"AIC"] # Akaike weight
if(messages==TRUE){ cat("\n\n - Computing Aw coefficients for each model vs. all previous models:")
cat("\n - null model vs.",fix.eff[1],": =",round(Weights(AICs),digits)[1],
"\n -",fix.eff[1],"vs. null model =",round(Weights(AICs),digits)[2]) }
if(length(models)>1){ for(i in 3:nrow(lrt)){ AICs <- c(AICs,lrt[i,"AIC"])
if(messages==TRUE){ cat("\n -",row.names(lrt)[i],"=",round(Weights(AICs),digits)[length(AICs)]) }}}
if(messages==TRUE){ cat("\n Selected model:",row.names(lrt[which(lrt$AIC==min(lrt$AIC)),])) }
if("key.results"%in%outputs){
key <- lrt[which(grepl(key.predictor,row.names(lrt))),] # key results
if(nrow(key)>1){ key <- key[1,] }
key.results <- data.frame(sig.LRT=key[,ncol(key)]<0.05,higher.Aw=key$AIC==min(AICs[1:(which(fix.eff==key.predictor)+1)])) }}
# estimated parameters from key.model
if("key.results"%in%outputs){
modSummary <- summary(models[[which(fix.eff==key.model)]])
modSummary <- modSummary$coefficients
if(modelType=="CLMM"){ modSummary <- modSummary[nlevels(long[,resp]):nrow(modSummary),] }
key <- modSummary[which(grepl(key.predictor,row.names(modSummary))),3][1] # taking only first coeff for key.results
key.results <- cbind(key.results,t.196=abs(key)>1.96,t=key) }
if("coeff"%in%outputs){ if(messages==TRUE){ suppressMessages(suppressWarnings(require(knitr)))
cat("\n\n - Printing estimated coefficients for models",paste(coeff.models,collapse=" , "))}
suppressMessages(suppressWarnings(require(XML))); suppressMessages(suppressWarnings(require(sjPlot)))
out <- data.frame(readHTMLTable(htmlParse(tab_model(models[which(fix.eff%in%coeff.models)],transform=transform,
show.icc=FALSE,show.p=FALSE,show.stat=TRUE,show.re.var=FALSE,
show.ci=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
string.est="B (SE)",string.stat="t")))[1])
colnames(out) <- out[1,]
out <- out[-1,] # sorting rows and columns
out <- rbind(out[which(!substr(out$Predictors,1,3)%in%c("SD ","Cor")),],
out[which(substr(out$Predictors,1,3)=="SD "),],out[which(substr(out$Predictors,1,4)=="Cor "),])
print(knitr::kable(out)) }
# plotting effects
if("plotEff"%in%outputs){ if(messages==TRUE){ cat("\n\n - Plotting effect(s) estimated by model",which(fix.eff==plot.model)) }
suppressMessages(suppressWarnings(require(sjPlot))); suppressMessages(suppressWarnings(require(ggplot2)))
if(plot.pred[1]=="all"){ fix.eff.plot <- fix.eff } else { fix.eff.plot <- plot.pred }
if(length(fix.eff.plot)==1){ if(grepl(":",plot.pred)){
terms <- c(strsplit(plot.pred,split=":")[[1]][1],strsplit(plot.pred,split=":")[[1]][2])
} else { terms <- fix.eff[which(fix.eff==fix.eff.plot)] }
p <- plot_model(models[[which(fix.eff==fix.eff.plot)]],type="pred",terms=terms,ci.lv=ci.lv,dodge=dodge,
show.data=show.data,dot.size=dot.size,jitter=0.15) + ggtitle(paste(resp,"by",fix.eff.plot,fix.eff.plot))
if(!is.na(y.lim[1])){ p <- p + ylim(y.lim) }
if(return.plot==TRUE){ return(p) } else { print(p) } # returning or printing the plot
} else { plots <- list()
for(i in 1:length(fix.eff.plot)){ if(grepl(":",fix.eff.plot[i],fixed=TRUE)==FALSE){ # predicted effects conditioned on ran.eff.
p <- plot_model(models[[i]],type="pred",terms=fix.eff.plot[i],show.data=show.data,dot.size=dot.size,ci.lv=ci.lv,
colors="gray",jitter=0.15,dodge=dodge)
} else { p <- plot_model(models[[i]],type="pred",terms=strsplit(fix.eff.plot[i],split=":")[[1]],ci.lv=ci.lv,dodge=dodge) }
plots[[i]] <- p + ggtitle(paste(resp,"by",fix.eff.plot[i])) }
plot_grid(plots,tags=TRUE,margin=rep(0,4)) }}
# returning key results (sig. LRT, Aw higher than previous model, t > 1.96)
if("key.results"%in%outputs){ return(key.results) }}
Fits GLM(ER) models and prints the core numeric and graphical ouputs considered for the analyses.
key.resPlot (from https://github.com/Luca-Menghini/LuMenPsy.Rfunctions )
key.resPlot <- function(res=NA,robCheck=NA,levels=c(s.archit,s.timing,paste(s.variab,"c",sep=""),s.auton)){
suppressMessages(suppressWarnings(require(ggplot2)))
# setting color scale
res[res$t.196==TRUE & res$sig.LRT==TRUE & res$higher.Aw==TRUE,"Value"] <- 10 # 10 = substantial effect
res[res$t.196==TRUE & ((res$sig.LRT==FALSE & res$higher.Aw==TRUE) |
res$sig.LRT==TRUE & res$higher.Aw==FALSE),"Value"] <- 7.5 # 7.5 = substantial but LRT n.s. OR lower Aw
res[res$t.196==TRUE & res$sig.LRT==FALSE & res$higher.Aw==FALSE,"Value"] <- 5 # 5 = substantial but both LRT n.s. AND lower Aw
res[res$t.196==FALSE & ((res$sig.LRT==TRUE & res$higher.Aw==TRUE) | (res$sig.LRT==TRUE & res$higher.Aw==FALSE) |
res$sig.LRT==FALSE & res$higher.Aw==TRUE),"Value"] <- 2.5 # 2.5 = unsubstantial and LRT n.s. OR lower Aw
res[res$t.196==FALSE & res$sig.LRT==FALSE & res$higher.Aw==FALSE,"Value"] <- 1 # 1 = no evidence at all
res$Measure <- factor(res$measure,levels=levels) # Measures as factor
# plotting
if(is.na(robCheck)){ # single set of analyses
ggplot(res,aes(x=Measure,y=as.factor(1),fill=Value)) + geom_tile() + geom_text(aes(label=round(t,2))) +
scale_fill_gradient2(low="red",high="lightgreen",mid="yellow",midpoint=5,limit = c(1,10), space = "Lab") +
labs(x="",y="") + theme(legend.position = "none",axis.text.y = element_blank(),axis.text.x=element_text(angle=45))
} else { require(reshape2) # multiple robustness checks
colnames(res)[which(colnames(res)==robCheck)] <- "robCheck"
ggplot(res,aes(x=Measure, y=as.factor(robCheck), fill=Value)) + geom_tile() + geom_text(aes(label=round(t,2))) +
scale_fill_gradient2(low="red",high="lightgreen",mid="yellow",midpoint=5,limit = c(1,10), space = "Lab") +
labs(x="",y="") + theme(legend.position = "none",axis.text.x=element_text(angle=45)) }}
Visualizes the key results (Aw, LRT, and t value) obtained with the glmerAn function.
Here, s.archit, s.timing, s.variab, and s.auton variables are predicted by the predictors selected in step 1 in addition to (1) the diary ratings measured at day i, and (2) the diary ratings measured at day i+1, in order to evaluate the direct and bidirectional relationship between sleep and psychological distress, as well as (3) the interaction between previous day diary ratings and insomnia. A random slope is also included to account for the individual variability in the relationship between diary ratings and sleep.
Here, we code the next day diary ratings.
# selecting all diaryVars variables
diaryVars <- c("stress","worry","mood","PsyDist","fs.w")
# computing lead variables (i.e., next day, "nd")
library(dplyr)
for(i in 1:length(diaryVars)){
colnames(ema)[colnames(ema)==diaryVars[i]] <- "variable"
ema <- ema %>% group_by(ID) %>% mutate(variable.nd=dplyr::lead(variable,n=1,default=NA)) # computing lead var
ema[ema$dayNr!=ema$partdayNr,"variable.nd"] <- NA # removing lagged values in cases when dayNr != partdayNr
colnames(ema) <- gsub("variable",diaryVars[i],colnames(ema)) }
ema <- as.data.frame(ema)
detach("package:dplyr", unload=TRUE)
# correlation between PsyDist and PsyDist.nd: .34-.50 (quite high) -> risk for multicollinearity?
cor(ema$stress,ema$stress.nd,use="complete.obs")
## [1] 0.4163984
cor(ema$worry,ema$worry.nd,use="complete.obs")
## [1] 0.4611379
cor(ema$mood,ema$mood.nd,use="complete.obs")
## [1] 0.3458227
cor(ema$PsyDist,ema$PsyDist.nd,use="complete.obs")
## [1] 0.5100607
cor(ema$fs.w,ema$fs.w.nd,use="complete.obs")
## [1] 0.2734142
# printing info
cat(nrow(ema),"total cases\n",nrow(ema[!is.na(ema$TIB),]),"with sleep.timing\n",
nrow(ema[!is.na(ema$TIB) & !is.na(ema$PsyDist),]),"with both sleep.timing and PsyDist\n",
nrow(ema[!is.na(ema$TIB) & !is.na(ema$PsyDist) & !is.na(ema$PsyDist.nd),]),"with sleep.timing, PsyDist, and PsyDist.nd")
## 6219 total cases
## 5121 with sleep.timing
## 4333 with both sleep.timing and PsyDist
## 3798 with sleep.timing, PsyDist, and PsyDist.nd
# changing variable name for better compatibility with the function below
colnames(ema)[which(colnames(ema)%in%c("stress.nd","worry.nd","mood.nd","PsyDist.nd","fs.w.nd"))] <-
c("s.nd","w.nd","m.nd","P.nd","f.nd")
s.archit variables are modeled by considering the subset of complete s.archit and dailyDiary data, whereas dailyAct data are ignored since none of the s.archit variables was substantially predicted by TotalSteps1000. Sex is excluded as well, since it only predicted small differences in some s.archit, but not in diary ratings.
s.archit <- c("TIB","TST","WASO","SE","light.p","deep.p","rem.p")
In section 5.1, TIB was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter TIB for later than usual SO) and weekday.sleep (longer TIB during weekend). Note that the random slope for stress is not included due to convergence problems.
# selecting core predictors
res <- res.nd <- res.int <- list() # empty list of key results
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TIB by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" # removing random slopes due to convergence problems
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") } # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results (considering M3 which showed higher Aw than M2 for all predictors)
res[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff, # day i (M3)
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[2],messages=FALSE))
res.nd[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff, # day i+1 (M3)
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE))
res.int[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff, # interaction (M4)
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE))
# showing analysis
glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing TIB by stress
## ###########################################
##
## Running GLMER analysis of TIB ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): TIB ~ (1|ID)
## - model M1: TIB ~ SO.num.mc + (1|ID)
## - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TIB ~ SO.num.mc + weekday.sleep + stress.mc + (1|ID)
## - model M4: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (1|ID)
## - model M5: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
## - model M6: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
##
## Fitting GLMER models of TIB on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc weekday.sleep stress.mc s.nd.mc
## 1.037423 1.056067 2.306710 1.077631
## insomnia stress.mc:insomnia
## 1.000034 2.259939
##
##
## - Running likelihood ratio test:
## Selected model: s.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 44363.30| 44382.03| -22178.65| 44357.30| NA| NA| NA|
## |SO.num.mc | 4| 43471.00| 43495.97| -21731.50| 43463.00| 894.294| 1| 0.000|
## |weekday.sleep | 5| 43035.46| 43066.67| -21512.73| 43025.46| 437.543| 1| 0.000|
## |stress.mc | 6| 43005.85| 43043.31| -21496.93| 42993.85| 31.608| 1| 0.000|
## |s.nd.mc | 7| 42974.21| 43017.90| -21480.10| 42960.21| 33.645| 1| 0.000|
## |insomnia | 8| 42975.96| 43025.89| -21479.98| 42959.96| 0.251| 1| 0.617|
## |stress.mc:insomnia | 9| 42976.77| 43032.95| -21479.39| 42958.77| 1.186| 1| 0.276|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - stress.mc = 1
## - s.nd.mc = 1
## - insomnia = 0.294
## - stress.mc:insomnia = 0.164
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |451.51(4.52) |99.99 |451.96(4.52) |100.10 |449.73(6.35) |70.80 |
## |3 |SO.num.mc |-37.08(0.99) |-37.47 |-37.24(0.99) |-37.79 |-37.23(0.99) |-37.79 |
## |4 |weekday.sleep [weekend] |53.01(2.52) |21.07 |51.31(2.52) |20.35 |51.28(2.52) |20.34 |
## |5 |stress.mc |-6.78(1.20) |-5.63 |-5.17(1.23) |-4.21 |-6.62(1.81) |-3.66 |
## |8 |s.nd.mc | | |-7.18(1.24) |-5.81 |-7.22(1.24) |-5.85 |
## |9 |insomnia [1] | | | | |4.47(8.91) |0.50 |
## |10 |stress.mc * insomnia [1] | | | | |2.61(2.40) |1.09 |
## |11 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |12 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |40.99(NA) | |41.00(NA) | |40.92(NA) | |
## |7 |SD (Observations) |8.20(NA) | |8.18(NA) | |8.18(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB by worry
## ###########################################
##
## Running GLMER analysis of TIB ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): TIB ~ (1|ID)
## - model M1: TIB ~ SO.num.mc + (1|ID)
## - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TIB ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID)
## - model M4: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of TIB on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: worry.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 44363.30| 44382.03| -22178.65| 44357.30| NA| NA| NA|
## |SO.num.mc | 4| 43471.00| 43495.97| -21731.50| 43463.00| 894.294| 1| 0.000|
## |weekday.sleep | 5| 43035.46| 43066.67| -21512.73| 43025.46| 437.543| 1| 0.000|
## |worry.mc | 8| 42971.47| 43021.41| -21477.74| 42955.47| 69.991| 3| 0.000|
## |w.nd.mc | 9| 42972.68| 43028.86| -21477.34| 42954.68| 0.790| 1| 0.374|
## |insomnia | 10| 42974.44| 43036.86| -21477.22| 42954.44| 0.239| 1| 0.625|
## |worry.mc:insomnia | 11| 42976.44| 43045.10| -21477.22| 42954.44| 0.004| 1| 0.952|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - worry.mc = 1
## - w.nd.mc = 0.353
## - insomnia = 0.128
## - worry.mc:insomnia = 0.045
## Selected model: worry.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |451.75(4.52) |100.05 |451.74(4.52) |100.05 |449.54(6.35) |70.77 |
## |3 |SO.num.mc |-37.19(0.99) |-37.69 |-37.17(0.99) |-37.67 |-37.17(0.99) |-37.67 |
## |4 |weekday.sleep [weekend] |51.98(2.51) |20.74 |52.03(2.51) |20.76 |52.02(2.51) |20.75 |
## |5 |worry.mc |-9.09(1.64) |-5.53 |-9.31(1.67) |-5.59 |-9.41(2.40) |-3.92 |
## |10 |w.nd.mc | | |1.12(1.26) |0.89 |1.12(1.26) |0.89 |
## |11 |insomnia [1] | | | | |4.39(8.91) |0.49 |
## |12 |worry.mc * insomnia [1] | | | | |0.20(3.29) |0.06 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |41.03(NA) | |41.03(NA) | |40.95(NA) | |
## |7 |SD (worry.mc) |9.43(NA) | |9.48(NA) | |9.48(NA) | |
## |9 |SD (Observations) |8.16(NA) | |8.16(NA) | |8.16(NA) | |
## |8 |Cor (Intercept~ID) |0.30(NA) | |0.30(NA) | |0.30(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB by mood
## ###########################################
##
## Running GLMER analysis of TIB ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): TIB ~ (1|ID)
## - model M1: TIB ~ SO.num.mc + (1|ID)
## - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TIB ~ SO.num.mc + weekday.sleep + mood.mc + (mood.mc|ID)
## - model M4: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M5: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M6: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of TIB on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: mood.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 44363.30| 44382.03| -22178.65| 44357.30| NA| NA| NA|
## |SO.num.mc | 4| 43471.00| 43495.97| -21731.50| 43463.00| 894.294| 1| 0.000|
## |weekday.sleep | 5| 43035.46| 43066.67| -21512.73| 43025.46| 437.543| 1| 0.000|
## |mood.mc | 8| 43028.26| 43078.19| -21506.13| 43012.26| 13.204| 3| 0.004|
## |m.nd.mc | 9| 43030.12| 43086.30| -21506.06| 43012.12| 0.139| 1| 0.709|
## |insomnia | 10| 43031.62| 43094.04| -21505.81| 43011.62| 0.501| 1| 0.479|
## |mood.mc:insomnia | 11| 43033.12| 43101.78| -21505.56| 43011.12| 0.499| 1| 0.480|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - mood.mc = 0.973
## - m.nd.mc = 0.277
## - insomnia = 0.116
## - mood.mc:insomnia = 0.052
## Selected model: mood.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |451.23(4.51) |100.06 |451.24(4.51) |100.06 |449.00(6.34) |70.78 |
## |3 |SO.num.mc |-37.04(0.99) |-37.27 |-37.04(0.99) |-37.27 |-37.05(0.99) |-37.28 |
## |4 |weekday.sleep [weekend] |53.79(2.52) |21.33 |53.77(2.52) |21.32 |53.77(2.52) |21.32 |
## |5 |mood.mc |-3.32(1.50) |-2.22 |-3.27(1.50) |-2.17 |-2.07(2.26) |-0.91 |
## |10 |m.nd.mc | | |-0.47(1.26) |-0.37 |-0.45(1.26) |-0.36 |
## |11 |insomnia [1] | | | | |4.44(8.90) |0.50 |
## |12 |mood.mc * insomnia [1] | | | | |-2.14(3.02) |-0.71 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |40.93(NA) | |40.93(NA) | |40.85(NA) | |
## |7 |SD (mood.mc) |7.02(NA) | |7.00(NA) | |7.17(NA) | |
## |9 |SD (Observations) |8.20(NA) | |8.20(NA) | |8.20(NA) | |
## |8 |Cor (Intercept~ID) |0.54(NA) | |0.54(NA) | |0.55(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB by PsyDist
## ###########################################
##
## Running GLMER analysis of TIB ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): TIB ~ (1|ID)
## - model M1: TIB ~ SO.num.mc + (1|ID)
## - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of TIB on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: PsyDist.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 44363.30| 44382.03| -22178.65| 44357.30| NA| NA| NA|
## |SO.num.mc | 4| 43471.00| 43495.97| -21731.50| 43463.00| 894.294| 1| 0.000|
## |weekday.sleep | 5| 43035.46| 43066.67| -21512.73| 43025.46| 437.543| 1| 0.000|
## |PsyDist.mc | 8| 42973.53| 43023.47| -21478.77| 42957.53| 67.930| 3| 0.000|
## |P.nd.mc | 9| 42972.49| 43028.67| -21477.24| 42954.49| 3.040| 1| 0.081|
## |insomnia | 10| 42974.25| 43036.67| -21477.13| 42954.25| 0.239| 1| 0.625|
## |PsyDist.mc:insomnia | 11| 42976.24| 43044.90| -21477.12| 42954.24| 0.014| 1| 0.905|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - PsyDist.mc = 1
## - P.nd.mc = 0.627
## - insomnia = 0.206
## - PsyDist.mc:insomnia = 0.071
## Selected model: P.nd.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |451.74(4.52) |99.90 |451.81(4.52) |99.93 |449.56(6.36) |70.67 |
## |3 |SO.num.mc |-37.50(0.99) |-37.87 |-37.51(0.99) |-37.91 |-37.51(0.99) |-37.91 |
## |4 |weekday.sleep [weekend] |52.09(2.51) |20.74 |51.82(2.52) |20.60 |51.81(2.52) |20.60 |
## |5 |PsyDist.mc |-11.67(2.27) |-5.15 |-10.86(2.29) |-4.74 |-11.13(3.32) |-3.35 |
## |10 |P.nd.mc | | |-2.89(1.66) |-1.75 |-2.89(1.66) |-1.75 |
## |11 |insomnia [1] | | | | |4.49(8.92) |0.50 |
## |12 |PsyDist.mc * insomnia [1] | | | | |0.54(4.48) |0.12 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |41.08(NA) | |41.07(NA) | |40.99(NA) | |
## |7 |SD (PsyDist.mc) |14.07(NA) | |13.85(NA) | |13.86(NA) | |
## |9 |SD (Observations) |8.16(NA) | |8.15(NA) | |8.15(NA) | |
## |8 |Cor (Intercept~ID) |0.45(NA) | |0.46(NA) | |0.46(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB by fs.w
## ###########################################
##
## Running GLMER analysis of TIB ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): TIB ~ (1|ID)
## - model M1: TIB ~ SO.num.mc + (1|ID)
## - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TIB ~ SO.num.mc + weekday.sleep + fs.w + (fs.w|ID)
## - model M4: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M5: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of TIB on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 44363.30| 44382.03| -22178.65| 44357.30| NA| NA| NA|
## |SO.num.mc | 4| 43471.00| 43495.97| -21731.50| 43463.00| 894.294| 1| 0.000|
## |weekday.sleep | 5| 43035.46| 43066.67| -21512.73| 43025.46| 437.543| 1| 0.000|
## |fs.w | 8| 42973.37| 43023.31| -21478.69| 42957.37| 68.087| 3| 0.000|
## |f.nd | 9| 42974.43| 43030.61| -21478.22| 42956.43| 0.944| 1| 0.331|
## |insomnia | 10| 42976.17| 43038.60| -21478.09| 42956.17| 0.256| 1| 0.613|
## |fs.w:insomnia | 11| 42978.17| 43046.84| -21478.09| 42956.17| 0.000| 1| 0.999|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - fs.w = 1
## - f.nd = 0.371
## - insomnia = 0.134
## - fs.w:insomnia = 0.047
## Selected model: fs.w
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |451.77(4.52) |100.03 |451.80(4.52) |100.06 |449.62(6.35) |70.76 |
## |3 |SO.num.mc |-37.46(0.99) |-37.86 |-37.47(0.99) |-37.87 |-37.47(0.99) |-37.87 |
## |4 |weekday.sleep [weekend] |52.05(2.51) |20.73 |51.92(2.51) |20.65 |51.92(2.51) |20.65 |
## |5 |fs.w |-9.90(1.91) |-5.18 |-9.54(1.94) |-4.92 |-9.52(2.81) |-3.38 |
## |10 |f.nd | | |-1.37(1.41) |-0.97 |-1.36(1.41) |-0.97 |
## |11 |insomnia [1] | | | | |4.34(8.91) |0.49 |
## |12 |fs.w * insomnia [1] | | | | |0.00(3.80) |0.00 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |41.02(NA) | |41.01(NA) | |40.94(NA) | |
## |7 |SD (fs.w) |11.76(NA) | |11.65(NA) | |11.68(NA) | |
## |9 |SD (Observations) |8.16(NA) | |8.16(NA) | |8.16(NA) | |
## |8 |Cor (Intercept~ID) |0.44(NA) | |0.44(NA) | |0.44(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term
SO.num, weekday.sleep, all raw and aggregate diary ratings, and next day stress are associated with a significant LRT, whereas stronger evidence in terms of Aw is also shown by next day PsyDist
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all raw and aggregate diary ratings (with the weakest effect estimated for mood), and next day stress; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect
In section 5.1, TST was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter TST for later than usual SO) and weekday.sleep (longer TST during weekend). Note that the random slope for mood is not included due to convergence problems.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TST by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
if(diaryVars[i]=="mood"){ ran.eff <- "(1|ID)" # removing random slopes due to convergence problems
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") } # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results (considering M3 which showed higher Aw than M2 for all predictors)
res[[i]] <- rbind(res[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,ran.eff=ran.eff, #day i
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[2],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,ran.eff=ran.eff, #i+1
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing TST by stress
## ###########################################
##
## Running GLMER analysis of TST ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): TST ~ (1|ID)
## - model M1: TST ~ SO.num.mc + (1|ID)
## - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TST ~ SO.num.mc + weekday.sleep + stress.mc + (stress.mc|ID)
## - model M4: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of TST on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc weekday.sleep stress.mc s.nd.mc
## 1.035156 1.052812 2.164848 1.056543
## insomnia stress.mc:insomnia
## 1.052613 2.192303
##
##
## - Running likelihood ratio test:
## Selected model: s.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 43450.41| 43469.13| -21722.20| 43444.41| NA| NA| NA|
## |SO.num.mc | 4| 42626.24| 42651.21| -21309.12| 42618.24| 826.164| 1| 0.000|
## |weekday.sleep | 5| 42192.10| 42223.31| -21091.05| 42182.10| 436.147| 1| 0.000|
## |stress.mc | 8| 42157.32| 42207.26| -21070.66| 42141.32| 40.774| 3| 0.000|
## |s.nd.mc | 9| 42126.13| 42182.31| -21054.07| 42108.13| 33.188| 1| 0.000|
## |insomnia | 10| 42128.08| 42190.51| -21054.04| 42108.08| 0.048| 1| 0.827|
## |stress.mc:insomnia | 11| 42129.42| 42198.09| -21053.71| 42107.42| 0.662| 1| 0.416|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - stress.mc = 1
## - s.nd.mc = 1
## - insomnia = 0.274
## - stress.mc:insomnia = 0.123
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |399.04(3.82) |104.38 |399.44(3.82) |104.49 |397.94(5.38) |73.99 |
## |3 |SO.num.mc |-32.01(0.89) |-36.00 |-32.16(0.89) |-36.32 |-32.16(0.89) |-36.32 |
## |4 |weekday.sleep [weekend] |47.40(2.25) |21.04 |45.87(2.26) |20.31 |45.86(2.26) |20.31 |
## |5 |stress.mc |-6.65(1.33) |-4.99 |-5.24(1.34) |-3.90 |-6.35(1.92) |-3.30 |
## |10 |s.nd.mc | | |-6.41(1.11) |-5.78 |-6.43(1.11) |-5.80 |
## |11 |insomnia [1] | | | | |2.98(7.54) |0.40 |
## |12 |stress.mc * insomnia [1] | | | | |2.14(2.62) |0.82 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |34.49(NA) | |34.51(NA) | |34.46(NA) | |
## |7 |SD (stress.mc) |6.76(NA) | |6.66(NA) | |6.53(NA) | |
## |9 |SD (Observations) |7.74(NA) | |7.73(NA) | |7.73(NA) | |
## |8 |Cor (Intercept~ID) |0.38(NA) | |0.44(NA) | |0.44(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST by worry
## ###########################################
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00221588 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00221588 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00221588 (tol = 0.002, component 1)
## Running GLMER analysis of TST ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): TST ~ (1|ID)
## - model M1: TST ~ SO.num.mc + (1|ID)
## - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TST ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID)
## - model M4: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of TST on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00221588 (tol = 0.002, component 1)
##
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: worry.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 43450.41| 43469.13| -21722.20| 43444.41| NA| NA| NA|
## |SO.num.mc | 4| 42626.24| 42651.21| -21309.12| 42618.24| 826.164| 1| 0.000|
## |weekday.sleep | 5| 42192.10| 42223.31| -21091.05| 42182.10| 436.147| 1| 0.000|
## |worry.mc | 8| 42132.76| 42182.69| -21058.38| 42116.76| 65.340| 3| 0.000|
## |w.nd.mc | 9| 42134.06| 42190.24| -21058.03| 42116.06| 0.700| 1| 0.403|
## |insomnia | 10| 42135.90| 42198.33| -21057.95| 42115.90| 0.150| 1| 0.699|
## |worry.mc:insomnia | 11| 42137.90| 42206.57| -21057.95| 42115.90| 0.000| 1| 0.988|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - worry.mc = 1
## - w.nd.mc = 0.343
## - insomnia = 0.12
## - worry.mc:insomnia = 0.042
## Selected model: worry.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |399.26(3.82) |104.43 |399.26(3.82) |104.43 |397.79(5.38) |73.96 |
## |3 |SO.num.mc |-32.01(0.88) |-36.19 |-32.00(0.88) |-36.17 |-32.00(0.88) |-36.17 |
## |4 |weekday.sleep [weekend] |46.57(2.25) |20.73 |46.61(2.25) |20.74 |46.61(2.25) |20.74 |
## |5 |worry.mc |-7.89(1.48) |-5.33 |-8.09(1.50) |-5.38 |-8.11(2.16) |-3.75 |
## |10 |w.nd.mc | | |0.95(1.13) |0.84 |0.95(1.13) |0.84 |
## |11 |insomnia [1] | | | | |2.92(7.54) |0.39 |
## |12 |worry.mc * insomnia [1] | | | | |0.04(2.96) |0.01 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |34.52(NA) | |34.52(NA) | |34.47(NA) | |
## |7 |SD (worry.mc) |8.54(NA) | |8.57(NA) | |8.57(NA) | |
## |9 |SD (Observations) |7.72(NA) | |7.72(NA) | |7.72(NA) | |
## |8 |Cor (Intercept~ID) |0.18(NA) | |0.18(NA) | |0.18(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST by mood
## ###########################################
##
## Running GLMER analysis of TST ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): TST ~ (1|ID)
## - model M1: TST ~ SO.num.mc + (1|ID)
## - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TST ~ SO.num.mc + weekday.sleep + mood.mc + (1|ID)
## - model M4: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (1|ID)
## - model M5: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M6: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of TST on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 43450.41| 43469.13| -21722.20| 43444.41| NA| NA| NA|
## |SO.num.mc | 4| 42626.24| 42651.21| -21309.12| 42618.24| 826.164| 1| 0.000|
## |weekday.sleep | 5| 42192.10| 42223.31| -21091.05| 42182.10| 436.147| 1| 0.000|
## |mood.mc | 6| 42190.72| 42228.17| -21089.36| 42178.72| 3.379| 1| 0.066|
## |m.nd.mc | 7| 42192.31| 42236.01| -21089.16| 42178.31| 0.403| 1| 0.526|
## |insomnia | 8| 42194.16| 42244.10| -21089.08| 42178.16| 0.151| 1| 0.698|
## |mood.mc:insomnia | 9| 42196.02| 42252.20| -21089.01| 42178.02| 0.141| 1| 0.708|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - mood.mc = 0.666
## - m.nd.mc = 0.231
## - insomnia = 0.084
## - mood.mc:insomnia = 0.032
## Selected model: mood.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |398.86(3.82) |104.32 |398.87(3.82) |104.32 |397.40(5.38) |73.88 |
## |3 |SO.num.mc |-31.80(0.89) |-35.68 |-31.80(0.89) |-35.69 |-31.81(0.89) |-35.69 |
## |4 |weekday.sleep [weekend] |48.19(2.26) |21.31 |48.15(2.26) |21.28 |48.15(2.26) |21.28 |
## |5 |mood.mc |-2.08(1.13) |-1.84 |-2.00(1.14) |-1.75 |-1.50(1.75) |-0.86 |
## |8 |m.nd.mc | | |-0.72(1.13) |-0.63 |-0.71(1.13) |-0.63 |
## |9 |insomnia [1] | | | | |2.93(7.54) |0.39 |
## |10 |mood.mc * insomnia [1] | | | | |-0.85(2.28) |-0.38 |
## |11 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |12 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |34.47(NA) | |34.47(NA) | |34.42(NA) | |
## |7 |SD (Observations) |7.78(NA) | |7.78(NA) | |7.78(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST by PsyDist
## ###########################################
##
## Running GLMER analysis of TST ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): TST ~ (1|ID)
## - model M1: TST ~ SO.num.mc + (1|ID)
## - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of TST on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: PsyDist.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 43450.41| 43469.13| -21722.20| 43444.41| NA| NA| NA|
## |SO.num.mc | 4| 42626.24| 42651.21| -21309.12| 42618.24| 826.164| 1| 0.000|
## |weekday.sleep | 5| 42192.10| 42223.31| -21091.05| 42182.10| 436.147| 1| 0.000|
## |PsyDist.mc | 8| 42137.89| 42187.82| -21060.94| 42121.89| 60.210| 3| 0.000|
## |P.nd.mc | 9| 42136.46| 42192.64| -21059.23| 42118.46| 3.424| 1| 0.064|
## |insomnia | 10| 42138.30| 42200.73| -21059.15| 42118.30| 0.158| 1| 0.691|
## |PsyDist.mc:insomnia | 11| 42140.30| 42208.97| -21059.15| 42118.30| 0.002| 1| 0.967|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - PsyDist.mc = 1
## - P.nd.mc = 0.671
## - insomnia = 0.211
## - PsyDist.mc:insomnia = 0.072
## Selected model: P.nd.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |399.28(3.83) |104.13 |399.34(3.83) |104.16 |397.83(5.39) |73.75 |
## |3 |SO.num.mc |-32.26(0.89) |-36.32 |-32.28(0.89) |-36.36 |-32.28(0.89) |-36.36 |
## |4 |weekday.sleep [weekend] |46.74(2.25) |20.75 |46.48(2.26) |20.60 |46.48(2.26) |20.60 |
## |5 |PsyDist.mc |-10.12(2.01) |-5.04 |-9.36(2.03) |-4.60 |-9.44(2.95) |-3.20 |
## |10 |P.nd.mc | | |-2.75(1.49) |-1.85 |-2.75(1.49) |-1.85 |
## |11 |insomnia [1] | | | | |3.01(7.56) |0.40 |
## |12 |PsyDist.mc * insomnia [1] | | | | |0.16(3.98) |0.04 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |34.62(NA) | |34.61(NA) | |34.56(NA) | |
## |7 |SD (PsyDist.mc) |12.23(NA) | |12.06(NA) | |12.07(NA) | |
## |9 |SD (Observations) |7.72(NA) | |7.72(NA) | |7.72(NA) | |
## |8 |Cor (Intercept~ID) |0.31(NA) | |0.32(NA) | |0.32(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST by fs.w
## ###########################################
##
## Running GLMER analysis of TST ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): TST ~ (1|ID)
## - model M1: TST ~ SO.num.mc + (1|ID)
## - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: TST ~ SO.num.mc + weekday.sleep + fs.w + (fs.w|ID)
## - model M4: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M5: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of TST on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 43450.41| 43469.13| -21722.20| 43444.41| NA| NA| NA|
## |SO.num.mc | 4| 42626.24| 42651.21| -21309.12| 42618.24| 826.164| 1| 0.000|
## |weekday.sleep | 5| 42192.10| 42223.31| -21091.05| 42182.10| 436.147| 1| 0.000|
## |fs.w | 8| 42136.91| 42186.84| -21060.45| 42120.91| 61.189| 3| 0.000|
## |f.nd | 9| 42137.68| 42193.86| -21059.84| 42119.68| 1.225| 1| 0.268|
## |insomnia | 10| 42139.52| 42201.94| -21059.76| 42119.52| 0.160| 1| 0.690|
## |fs.w:insomnia | 11| 42141.52| 42210.18| -21059.76| 42119.52| 0.005| 1| 0.946|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - fs.w = 1
## - f.nd = 0.404
## - insomnia = 0.139
## - fs.w:insomnia = 0.049
## Selected model: fs.w
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2 |(Intercept) |399.30(3.83) |104.27 |399.33(3.83) |104.32 |397.89(5.39) |73.86 |
## |3 |SO.num.mc |-32.23(0.89) |-36.32 |-32.24(0.89) |-36.33 |-32.24(0.89) |-36.33 |
## |4 |weekday.sleep [weekend] |46.69(2.25) |20.73 |46.57(2.25) |20.65 |46.57(2.26) |20.65 |
## |5 |fs.w |-8.57(1.71) |-5.02 |-8.21(1.73) |-4.74 |-8.08(2.51) |-3.21 |
## |10 |f.nd | | |-1.40(1.26) |-1.11 |-1.39(1.26) |-1.10 |
## |11 |insomnia [1] | | | | |2.88(7.55) |0.38 |
## |12 |fs.w * insomnia [1] | | | | |-0.23(3.40) |-0.07 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |34.57(NA) | |34.55(NA) | |34.51(NA) | |
## |7 |SD (fs.w) |10.38(NA) | |10.29(NA) | |10.31(NA) | |
## |9 |SD (Observations) |7.72(NA) | |7.72(NA) | |7.72(NA) | |
## |8 |Cor (Intercept~ID) |0.29(NA) | |0.30(NA) | |0.30(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc
SO.num, weekday.sleep, all raw and aggregate diary ratings, and next day stress are associated with a significant LRT, whereas stronger evidence in terms of Aw is also shown by next day PsyDist and fs
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all raw and aggregate diary ratings (with the weakest effect estimated for mood), and next day stress; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect
overall, the results are highly consistent with those reported for TIB
In section 5.1, WASO was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter WASO for later than usual SO) and weekday.sleep (longer WASO during weekend). Note that the random slope for mood is not included due to convergence problems (singular fit).
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WASO by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="mood"){ ran.eff <- "(1|ID)" } # removing random slope for mood to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results (considering M3 for stress and PsyDist which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]%in%c("stress","PsyDist","fs.w"),2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,ran.eff=ran.eff, # day i
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing WASO by stress
## ###########################################
##
## Running GLMER analysis of WASO ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): WASO ~ (1|ID)
## - model M1: WASO ~ SO.num.mc + (1|ID)
## - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO ~ SO.num.mc + weekday.sleep + stress.mc + (stress.mc|ID)
## - model M4: WASO ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: WASO ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: WASO ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of WASO on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc weekday.sleep stress.mc s.nd.mc
## 1.035342 1.053177 2.172957 1.058550
## insomnia stress.mc:insomnia
## 1.006861 2.147784
##
##
## - Running likelihood ratio test:
## Selected model: s.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 33835.76| 33854.49| -16914.88| 33829.76| NA| NA| NA|
## |SO.num.mc | 4| 33534.36| 33559.33| -16763.18| 33526.36| 303.401| 1| 0.000|
## |weekday.sleep | 5| 33462.29| 33493.50| -16726.15| 33452.29| 74.068| 1| 0.000|
## |stress.mc | 8| 33456.43| 33506.36| -16720.21| 33440.43| 11.863| 3| 0.008|
## |s.nd.mc | 9| 33448.15| 33504.33| -16715.08| 33430.15| 10.273| 1| 0.001|
## |insomnia | 10| 33449.77| 33512.19| -16714.89| 33429.77| 0.381| 1| 0.537|
## |stress.mc:insomnia | 11| 33450.35| 33519.01| -16714.17| 33428.35| 1.426| 1| 0.232|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - stress.mc = 0.949
## - s.nd.mc = 0.983
## - insomnia = 0.304
## - stress.mc:insomnia = 0.186
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |46.39(1.17) |39.59 |46.46(1.17) |39.65 |45.63(1.64) |27.74 |
## |3 |SO.num.mc |-5.51(0.28) |-19.46 |-5.53(0.28) |-19.57 |-5.53(0.28) |-19.56 |
## |4 |weekday.sleep [weekend] |5.97(0.72) |8.33 |5.70(0.72) |7.90 |5.70(0.72) |7.90 |
## |5 |stress.mc |-0.92(0.41) |-2.23 |-0.67(0.42) |-1.60 |-1.19(0.60) |-1.98 |
## |10 |s.nd.mc | | |-1.14(0.35) |-3.21 |-1.15(0.35) |-3.24 |
## |11 |insomnia [1] | | | | |1.66(2.30) |0.72 |
## |12 |stress.mc * insomnia [1] | | | | |0.98(0.82) |1.20 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |10.52(NA) | |10.52(NA) | |10.49(NA) | |
## |7 |SD (stress.mc) |1.96(NA) | |1.96(NA) | |1.90(NA) | |
## |9 |SD (Observations) |4.37(NA) | |4.37(NA) | |4.37(NA) | |
## |8 |Cor (Intercept~ID) |0.17(NA) | |0.19(NA) | |0.17(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO by worry
## ###########################################
##
## Running GLMER analysis of WASO ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): WASO ~ (1|ID)
## - model M1: WASO ~ SO.num.mc + (1|ID)
## - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID)
## - model M4: WASO ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: WASO ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: WASO ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of WASO on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: worry.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 33835.76| 33854.49| -16914.88| 33829.76| NA| NA| NA|
## |SO.num.mc | 4| 33534.36| 33559.33| -16763.18| 33526.36| 303.401| 1| 0.000|
## |weekday.sleep | 5| 33462.29| 33493.50| -16726.15| 33452.29| 74.068| 1| 0.000|
## |worry.mc | 8| 33459.64| 33509.57| -16721.82| 33443.64| 8.655| 3| 0.034|
## |w.nd.mc | 9| 33461.58| 33517.76| -16721.79| 33443.58| 0.050| 1| 0.823|
## |insomnia | 10| 33463.07| 33525.49| -16721.53| 33443.07| 0.515| 1| 0.473|
## |worry.mc:insomnia | 11| 33465.07| 33533.73| -16721.53| 33443.07| 0.000| 1| 0.996|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - worry.mc = 0.79
## - w.nd.mc = 0.23
## - insomnia = 0.099
## - worry.mc:insomnia = 0.035
## Selected model: worry.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |46.38(1.17) |39.57 |46.38(1.17) |39.57 |45.55(1.65) |27.68 |
## |3 |SO.num.mc |-5.47(0.28) |-19.37 |-5.47(0.28) |-19.36 |-5.47(0.28) |-19.36 |
## |4 |weekday.sleep [weekend] |5.98(0.72) |8.32 |5.98(0.72) |8.32 |5.98(0.72) |8.32 |
## |5 |worry.mc |-0.93(0.39) |-2.39 |-0.95(0.40) |-2.39 |-0.95(0.58) |-1.65 |
## |10 |w.nd.mc | | |0.08(0.36) |0.22 |0.08(0.36) |0.22 |
## |11 |insomnia [1] | | | | |1.65(2.31) |0.72 |
## |12 |worry.mc * insomnia [1] | | | | |0.00(0.78) |0.01 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |10.52(NA) | |10.52(NA) | |10.49(NA) | |
## |7 |SD (worry.mc) |1.40(NA) | |1.41(NA) | |1.41(NA) | |
## |9 |SD (Observations) |4.37(NA) | |4.37(NA) | |4.37(NA) | |
## |8 |Cor (Intercept~ID) |-0.18(NA) | |-0.18(NA) | |-0.18(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO by mood
## ###########################################
##
## Running GLMER analysis of WASO ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): WASO ~ (1|ID)
## - model M1: WASO ~ SO.num.mc + (1|ID)
## - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO ~ SO.num.mc + weekday.sleep + mood.mc + (1|ID)
## - model M4: WASO ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (1|ID)
## - model M5: WASO ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M6: WASO ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of WASO on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 33835.76| 33854.49| -16914.88| 33829.76| NA| NA| NA|
## |SO.num.mc | 4| 33534.36| 33559.33| -16763.18| 33526.36| 303.401| 1| 0.000|
## |weekday.sleep | 5| 33462.29| 33493.50| -16726.15| 33452.29| 74.068| 1| 0.000|
## |mood.mc | 6| 33463.36| 33500.81| -16725.68| 33451.36| 0.934| 1| 0.334|
## |m.nd.mc | 7| 33465.22| 33508.92| -16725.61| 33451.22| 0.134| 1| 0.714|
## |insomnia | 8| 33466.71| 33516.65| -16725.36| 33450.71| 0.508| 1| 0.476|
## |mood.mc:insomnia | 9| 33468.71| 33524.89| -16725.36| 33450.71| 0.001| 1| 0.972|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - mood.mc = 0.37
## - m.nd.mc = 0.127
## - insomnia = 0.057
## - mood.mc:insomnia = 0.02
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |46.34(1.17) |39.53 |46.34(1.17) |39.53 |45.51(1.65) |27.65 |
## |3 |SO.num.mc |-5.44(0.28) |-19.25 |-5.44(0.28) |-19.25 |-5.44(0.28) |-19.25 |
## |4 |weekday.sleep [weekend] |6.13(0.72) |8.54 |6.14(0.72) |8.55 |6.14(0.72) |8.55 |
## |5 |mood.mc |-0.35(0.36) |-0.97 |-0.36(0.36) |-1.00 |-0.35(0.55) |-0.63 |
## |8 |m.nd.mc | | |0.13(0.36) |0.37 |0.13(0.36) |0.37 |
## |9 |insomnia [1] | | | | |1.65(2.31) |0.71 |
## |10 |mood.mc * insomnia [1] | | | | |-0.03(0.72) |-0.03 |
## |11 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |12 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |10.52(NA) | |10.52(NA) | |10.49(NA) | |
## |7 |SD (Observations) |4.38(NA) | |4.38(NA) | |4.38(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO by PsyDist
## ###########################################
##
## Running GLMER analysis of WASO ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): WASO ~ (1|ID)
## - model M1: WASO ~ SO.num.mc + (1|ID)
## - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO ~ SO.num.mc + weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: WASO ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: WASO ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: WASO ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of WASO on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: PsyDist.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 33835.76| 33854.49| -16914.88| 33829.76| NA| NA| NA|
## |SO.num.mc | 4| 33534.36| 33559.33| -16763.18| 33526.36| 303.401| 1| 0.000|
## |weekday.sleep | 5| 33462.29| 33493.50| -16726.15| 33452.29| 74.068| 1| 0.000|
## |PsyDist.mc | 8| 33456.42| 33506.36| -16720.21| 33440.42| 11.868| 3| 0.008|
## |P.nd.mc | 9| 33457.76| 33513.94| -16719.88| 33439.76| 0.665| 1| 0.415|
## |insomnia | 10| 33459.29| 33521.71| -16719.65| 33439.29| 0.464| 1| 0.496|
## |PsyDist.mc:insomnia | 11| 33460.98| 33529.64| -16719.49| 33438.98| 0.314| 1| 0.576|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - PsyDist.mc = 0.95
## - P.nd.mc = 0.327
## - insomnia = 0.132
## - PsyDist.mc:insomnia = 0.054
## Selected model: PsyDist.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |46.40(1.17) |39.59 |46.41(1.17) |39.59 |45.59(1.65) |27.71 |
## |3 |SO.num.mc |-5.52(0.28) |-19.50 |-5.52(0.28) |-19.51 |-5.52(0.28) |-19.50 |
## |4 |weekday.sleep [weekend] |5.92(0.72) |8.23 |5.88(0.72) |8.16 |5.87(0.72) |8.15 |
## |5 |PsyDist.mc |-1.32(0.54) |-2.43 |-1.21(0.56) |-2.18 |-1.54(0.81) |-1.90 |
## |10 |P.nd.mc | | |-0.39(0.47) |-0.82 |-0.39(0.47) |-0.83 |
## |11 |insomnia [1] | | | | |1.63(2.30) |0.71 |
## |12 |PsyDist.mc * insomnia [1] | | | | |0.60(1.08) |0.56 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |10.52(NA) | |10.52(NA) | |10.49(NA) | |
## |7 |SD (PsyDist.mc) |2.49(NA) | |2.45(NA) | |2.42(NA) | |
## |9 |SD (Observations) |4.37(NA) | |4.37(NA) | |4.37(NA) | |
## |8 |Cor (Intercept~ID) |0.12(NA) | |0.12(NA) | |0.11(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO by fs.w
## ###########################################
##
## Running GLMER analysis of WASO ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): WASO ~ (1|ID)
## - model M1: WASO ~ SO.num.mc + (1|ID)
## - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO ~ SO.num.mc + weekday.sleep + fs.w + (fs.w|ID)
## - model M4: WASO ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M5: WASO ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: WASO ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of WASO on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 33835.76| 33854.49| -16914.88| 33829.76| NA| NA| NA|
## |SO.num.mc | 4| 33534.36| 33559.33| -16763.18| 33526.36| 303.401| 1| 0.000|
## |weekday.sleep | 5| 33462.29| 33493.50| -16726.15| 33452.29| 74.068| 1| 0.000|
## |fs.w | 8| 33458.00| 33507.94| -16721.00| 33442.00| 10.291| 3| 0.016|
## |f.nd | 9| 33459.80| 33515.98| -16720.90| 33441.80| 0.202| 1| 0.653|
## |insomnia | 10| 33461.32| 33523.74| -16720.66| 33441.32| 0.475| 1| 0.491|
## |fs.w:insomnia | 11| 33463.15| 33531.81| -16720.57| 33441.15| 0.175| 1| 0.676|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - fs.w = 0.895
## - f.nd = 0.267
## - insomnia = 0.111
## - fs.w:insomnia = 0.043
## Selected model: fs.w
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |46.40(1.17) |39.60 |46.40(1.17) |39.60 |45.59(1.65) |27.71 |
## |3 |SO.num.mc |-5.51(0.28) |-19.47 |-5.51(0.28) |-19.47 |-5.51(0.28) |-19.47 |
## |4 |weekday.sleep [weekend] |5.93(0.72) |8.24 |5.92(0.72) |8.21 |5.91(0.72) |8.20 |
## |5 |fs.w |-1.09(0.45) |-2.42 |-1.04(0.46) |-2.26 |-1.25(0.68) |-1.84 |
## |10 |f.nd | | |-0.18(0.40) |-0.45 |-0.18(0.40) |-0.46 |
## |11 |insomnia [1] | | | | |1.62(2.30) |0.70 |
## |12 |fs.w * insomnia [1] | | | | |0.37(0.89) |0.42 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |10.52(NA) | |10.52(NA) | |10.48(NA) | |
## |7 |SD (fs.w) |1.91(NA) | |1.89(NA) | |1.87(NA) | |
## |9 |SD (Observations) |4.37(NA) | |4.37(NA) | |4.37(NA) | |
## |8 |Cor (Intercept~ID) |0.10(NA) | |0.10(NA) | |0.09(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
SO.num, weekday.sleep, stress, worry (but not mood), PsyDist, fs, and next day stress are associated with a significant LRT, and with stronger evidence in terms of Aw
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all raw and aggregate diary ratings with the only exception of mood and stress (only substantial in model M2 but not in the selected model M3), and for next day stress; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect
In section 5.1, SE was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SO.num (higher SE for later than usual SO). Note that the random slope for worry and mood are not included due to convergence problems (singular fit).
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SE by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","mood")){ ran.eff <- "(1|ID)" } # removing random slope for stress and mood to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,ran.eff=ran.eff, # day i
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing SE by stress
## ###########################################
##
## Running GLMER analysis of SE ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): SE ~ (1|ID)
## - model M1: SE ~ SO.num.mc + (1|ID)
## - model M2: SE ~ SO.num.mc + stress.mc + (stress.mc|ID)
## - model M3: SE ~ SO.num.mc + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M4: SE ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M5: SE ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of SE on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc stress.mc s.nd.mc insomnia
## 1.005329 2.160582 1.042615 1.000682
## stress.mc:insomnia
## 2.132631
##
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 20367.88| 20386.61| -10180.94| 20361.88| NA| NA| NA|
## |SO.num.mc | 4| 20360.08| 20385.05| -10176.04| 20352.08| 9.795| 1| 0.002|
## |stress.mc | 7| 20360.87| 20404.56| -10173.43| 20346.87| 5.215| 3| 0.157|
## |s.nd.mc | 8| 20362.56| 20412.50| -10173.28| 20346.56| 0.311| 1| 0.577|
## |insomnia | 9| 20364.27| 20420.46| -10173.14| 20346.27| 0.284| 1| 0.594|
## |stress.mc:insomnia | 10| 20366.13| 20428.55| -10173.07| 20346.13| 0.142| 1| 0.706|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - stress.mc = 0.398
## - s.nd.mc = 0.146
## - insomnia = 0.058
## - stress.mc:insomnia = 0.023
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |88.52(0.21) |429.38 |88.52(0.21) |429.38 |88.62(0.29) |303.44 |
## |3 |SO.num.mc |0.16(0.05) |3.27 |0.16(0.05) |3.30 |0.16(0.05) |3.29 |
## |4 |stress.mc |-0.02(0.07) |-0.33 |-0.03(0.08) |-0.43 |-0.00(0.11) |-0.02 |
## |9 |s.nd.mc | | |0.03(0.06) |0.56 |0.04(0.06) |0.57 |
## |10 |insomnia [1] | | | | |-0.22(0.41) |-0.52 |
## |11 |stress.mc * insomnia [1] | | | | |-0.06(0.15) |-0.38 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |5 |SD (Intercept) |1.88(NA) | |1.88(NA) | |1.87(NA) | |
## |6 |SD (stress.mc) |0.36(NA) | |0.36(NA) | |0.36(NA) | |
## |8 |SD (Observations) |1.85(NA) | |1.85(NA) | |1.85(NA) | |
## |7 |Cor (Intercept~ID) |-0.05(NA) | |-0.05(NA) | |-0.05(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SE by worry
## ###########################################
##
## Running GLMER analysis of SE ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): SE ~ (1|ID)
## - model M1: SE ~ SO.num.mc + (1|ID)
## - model M2: SE ~ SO.num.mc + worry.mc + (1|ID)
## - model M3: SE ~ SO.num.mc + worry.mc + w.nd.mc + (1|ID)
## - model M4: SE ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + (1|ID)
## - model M5: SE ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
##
## Fitting GLMER models of SE on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 20367.88| 20386.61| -10180.94| 20361.88| NA| NA| NA|
## |SO.num.mc | 4| 20360.08| 20385.05| -10176.04| 20352.08| 9.795| 1| 0.002|
## |worry.mc | 5| 20361.81| 20393.03| -10175.91| 20351.81| 0.271| 1| 0.603|
## |w.nd.mc | 6| 20363.78| 20401.24| -10175.89| 20351.78| 0.031| 1| 0.860|
## |insomnia | 7| 20365.51| 20409.20| -10175.75| 20351.51| 0.274| 1| 0.601|
## |worry.mc:insomnia | 8| 20367.48| 20417.42| -10175.74| 20351.48| 0.027| 1| 0.870|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - worry.mc = 0.292
## - w.nd.mc = 0.098
## - insomnia = 0.04
## - worry.mc:insomnia = 0.015
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |88.52(0.21) |429.53 |88.52(0.21) |429.53 |88.62(0.29) |303.55 |
## |3 |SO.num.mc |0.16(0.05) |3.16 |0.16(0.05) |3.16 |0.16(0.05) |3.16 |
## |4 |worry.mc |0.03(0.06) |0.52 |0.03(0.06) |0.47 |0.04(0.09) |0.44 |
## |7 |w.nd.mc | | |0.01(0.06) |0.18 |0.01(0.06) |0.18 |
## |8 |insomnia [1] | | | | |-0.22(0.41) |-0.52 |
## |9 |worry.mc * insomnia [1] | | | | |-0.02(0.13) |-0.16 |
## |10 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |11 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |5 |SD (Intercept) |1.88(NA) | |1.88(NA) | |1.87(NA) | |
## |6 |SD (Observations) |1.85(NA) | |1.85(NA) | |1.85(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SE by mood
## ###########################################
##
## Running GLMER analysis of SE ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): SE ~ (1|ID)
## - model M1: SE ~ SO.num.mc + (1|ID)
## - model M2: SE ~ SO.num.mc + mood.mc + (1|ID)
## - model M3: SE ~ SO.num.mc + mood.mc + m.nd.mc + (1|ID)
## - model M4: SE ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M5: SE ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of SE on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 20367.88| 20386.61| -10180.94| 20361.88| NA| NA| NA|
## |SO.num.mc | 4| 20360.08| 20385.05| -10176.04| 20352.08| 9.795| 1| 0.002|
## |mood.mc | 5| 20361.84| 20393.05| -10175.92| 20351.84| 0.243| 1| 0.622|
## |m.nd.mc | 6| 20363.43| 20400.88| -10175.71| 20351.43| 0.413| 1| 0.520|
## |insomnia | 7| 20365.15| 20408.85| -10175.58| 20351.15| 0.274| 1| 0.601|
## |mood.mc:insomnia | 8| 20366.88| 20416.82| -10175.44| 20350.88| 0.275| 1| 0.600|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - mood.mc = 0.289
## - m.nd.mc = 0.116
## - insomnia = 0.047
## - mood.mc:insomnia = 0.019
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |88.52(0.21) |429.53 |88.52(0.21) |429.53 |88.62(0.29) |303.55 |
## |3 |SO.num.mc |0.16(0.05) |3.16 |0.16(0.05) |3.16 |0.16(0.05) |3.16 |
## |4 |mood.mc |0.03(0.06) |0.49 |0.04(0.06) |0.56 |-0.00(0.10) |-0.03 |
## |7 |m.nd.mc | | |-0.04(0.06) |-0.64 |-0.04(0.06) |-0.65 |
## |8 |insomnia [1] | | | | |-0.22(0.41) |-0.52 |
## |9 |mood.mc * insomnia [1] | | | | |0.07(0.13) |0.52 |
## |10 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |11 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |5 |SD (Intercept) |1.88(NA) | |1.88(NA) | |1.87(NA) | |
## |6 |SD (Observations) |1.85(NA) | |1.85(NA) | |1.85(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SE by PsyDist
## ###########################################
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00204863 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00204863 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00204863 (tol = 0.002, component 1)
## Running GLMER analysis of SE ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): SE ~ (1|ID)
## - model M1: SE ~ SO.num.mc + (1|ID)
## - model M2: SE ~ SO.num.mc + PsyDist.mc + (PsyDist.mc|ID)
## - model M3: SE ~ SO.num.mc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M4: SE ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M5: SE ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of SE on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00204863 (tol = 0.002, component 1)
##
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 20367.88| 20386.61| -10180.94| 20361.88| NA| NA| NA|
## |SO.num.mc | 4| 20360.08| 20385.05| -10176.04| 20352.08| 9.795| 1| 0.002|
## |PsyDist.mc | 7| 20364.72| 20408.42| -10175.36| 20350.72| 1.364| 3| 0.714|
## |P.nd.mc | 8| 20366.72| 20416.65| -10175.36| 20350.72| 0.005| 1| 0.945|
## |insomnia | 9| 20368.44| 20424.62| -10175.22| 20350.44| 0.276| 1| 0.599|
## |PsyDist.mc:insomnia | 10| 20370.44| 20432.86| -10175.22| 20350.44| 0.005| 1| 0.942|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - PsyDist.mc = 0.088
## - P.nd.mc = 0.031
## - insomnia = 0.013
## - PsyDist.mc:insomnia = 0.005
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |88.52(0.21) |429.07 |88.52(0.21) |429.05 |88.63(0.29) |303.23 |
## |3 |SO.num.mc |0.16(0.05) |3.21 |0.16(0.05) |3.21 |0.16(0.05) |3.21 |
## |4 |PsyDist.mc |0.02(0.09) |0.27 |0.03(0.09) |0.27 |0.03(0.14) |0.24 |
## |9 |P.nd.mc | | |-0.01(0.08) |-0.07 |-0.01(0.08) |-0.07 |
## |10 |insomnia [1] | | | | |-0.21(0.41) |-0.52 |
## |11 |PsyDist.mc * insomnia [1] | | | | |-0.01(0.18) |-0.07 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |5 |SD (Intercept) |1.88(NA) | |1.88(NA) | |1.88(NA) | |
## |6 |SD (PsyDist.mc) |0.30(NA) | |0.30(NA) | |0.30(NA) | |
## |8 |SD (Observations) |1.85(NA) | |1.85(NA) | |1.85(NA) | |
## |7 |Cor (Intercept~ID) |-0.19(NA) | |-0.19(NA) | |-0.19(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SE by fs.w
## ###########################################
##
## Running GLMER analysis of SE ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): SE ~ (1|ID)
## - model M1: SE ~ SO.num.mc + (1|ID)
## - model M2: SE ~ SO.num.mc + fs.w + (fs.w|ID)
## - model M3: SE ~ SO.num.mc + fs.w + f.nd + (fs.w|ID)
## - model M4: SE ~ SO.num.mc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M5: SE ~ SO.num.mc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of SE on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 20367.88| 20386.61| -10180.94| 20361.88| NA| NA| NA|
## |SO.num.mc | 4| 20360.08| 20385.05| -10176.04| 20352.08| 9.795| 1| 0.002|
## |fs.w | 7| 20365.12| 20408.81| -10175.56| 20351.12| 0.965| 3| 0.810|
## |f.nd | 8| 20367.11| 20417.05| -10175.56| 20351.11| 0.007| 1| 0.933|
## |insomnia | 9| 20368.84| 20425.02| -10175.42| 20350.84| 0.275| 1| 0.600|
## |fs.w:insomnia | 10| 20370.84| 20433.26| -10175.42| 20350.84| 0.000| 1| 0.992|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - fs.w = 0.073
## - f.nd = 0.026
## - insomnia = 0.011
## - fs.w:insomnia = 0.004
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2 |(Intercept) |88.52(0.21) |429.22 |88.52(0.21) |429.22 |88.63(0.29) |303.34 |
## |3 |SO.num.mc |0.16(0.05) |3.20 |0.16(0.05) |3.19 |0.16(0.05) |3.19 |
## |4 |fs.w |0.03(0.07) |0.37 |0.03(0.08) |0.38 |0.03(0.11) |0.27 |
## |9 |f.nd | | |-0.01(0.07) |-0.08 |-0.01(0.07) |-0.08 |
## |10 |insomnia [1] | | | | |-0.21(0.41) |-0.52 |
## |11 |fs.w * insomnia [1] | | | | |-0.00(0.15) |-0.01 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |5 |SD (Intercept) |1.88(NA) | |1.88(NA) | |1.87(NA) | |
## |6 |SD (fs.w) |0.19(NA) | |0.19(NA) | |0.19(NA) | |
## |8 |SD (Observations) |1.85(NA) | |1.85(NA) | |1.85(NA) | |
## |7 |Cor (Intercept~ID) |-0.32(NA) | |-0.32(NA) | |-0.32(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) residuals and (2) random effects are quite normally distributed, although a marked deviation from normality can be seen in the lower tail of the residuals distribution (i.e., SE is bounded at 100), with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
only SO.num is associated with a significant LRT, and showed stronger evidence in terms of Aw
coherently, SO.num is the only predictor showing a substantial relationship with SE
In section 5.1, light.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by BMI (lower light.p for participants with higher BMI). Note that the random slope for worry is not included due to convergence problems (singular fit).
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing light.p by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
if(diaryVars[i]=="worry"){ ran.eff <- "(1|ID)" # removing random slopes due to convergence problems
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") } # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",
fix.eff=predictors,ran.eff=ran.eff, # day i+1
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
outputs=outputs,ran.eff=ran.eff, # including random slope
coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing light.p by stress
## ###########################################
##
## Running GLMER analysis of light.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): light.p ~ (1|ID)
## - model M1: light.p ~ BMI.gmc + (1|ID)
## - model M2: light.p ~ BMI.gmc + stress.mc + (stress.mc|ID)
## - model M3: light.p ~ BMI.gmc + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M4: light.p ~ BMI.gmc + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M5: light.p ~ BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of light.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## BMI.gmc stress.mc s.nd.mc insomnia
## 1.032611 2.126515 1.050647 1.032725
## stress.mc:insomnia
## 2.092109
##
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 22070.82| 22089.10| -11032.41| 22064.82| NA| NA| NA|
## |BMI.gmc | 4| 22066.97| 22091.35| -11029.48| 22058.97| 5.852| 1| 0.016|
## |stress.mc | 7| 22070.71| 22113.37| -11028.36| 22056.71| 2.257| 3| 0.521|
## |s.nd.mc | 8| 22072.65| 22121.40| -11028.33| 22056.65| 0.062| 1| 0.804|
## |insomnia | 9| 22073.63| 22128.48| -11027.82| 22055.63| 1.017| 1| 0.313|
## |stress.mc:insomnia | 10| 22075.00| 22135.94| -11027.50| 22055.00| 0.634| 1| 0.426|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. BMI.gmc : = 0.127
## - BMI.gmc vs. null model = 0.873
## - stress.mc = 0.118
## - s.nd.mc = 0.043
## - insomnia = 0.026
## - stress.mc:insomnia = 0.013
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2 |(Intercept) |58.86(0.49) |119.85 |58.86(0.49) |119.85 |58.35(0.70) |83.53 |
## |3 |BMI.gmc |-0.37(0.15) |-2.46 |-0.37(0.15) |-2.46 |-0.35(0.15) |-2.27 |
## |4 |stress.mc |-0.10(0.14) |-0.72 |-0.11(0.15) |-0.75 |-0.23(0.21) |-1.09 |
## |9 |s.nd.mc | | |0.03(0.13) |0.25 |0.03(0.13) |0.22 |
## |10 |insomnia [1] | | | | |1.00(0.99) |1.01 |
## |11 |stress.mc * insomnia [1] | | | | |0.23(0.29) |0.80 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.49(NA) | |4.49(NA) | |4.45(NA) | |
## |6 |SD (stress.mc) |0.53(NA) | |0.53(NA) | |0.53(NA) | |
## |8 |SD (Observations) |2.60(NA) | |2.60(NA) | |2.60(NA) | |
## |7 |Cor (Intercept~ID) |0.00(NA) | |0.00(NA) | |-0.03(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing light.p by worry
## ###########################################
##
## Running GLMER analysis of light.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): light.p ~ (1|ID)
## - model M1: light.p ~ BMI.gmc + (1|ID)
## - model M2: light.p ~ BMI.gmc + worry.mc + (1|ID)
## - model M3: light.p ~ BMI.gmc + worry.mc + w.nd.mc + (1|ID)
## - model M4: light.p ~ BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
## - model M5: light.p ~ BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
##
## Fitting GLMER models of light.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 22070.82| 22089.10| -11032.41| 22064.82| NA| NA| NA|
## |BMI.gmc | 4| 22066.97| 22091.35| -11029.48| 22058.97| 5.852| 1| 0.016|
## |worry.mc | 5| 22067.65| 22098.12| -11028.82| 22057.65| 1.320| 1| 0.251|
## |w.nd.mc | 6| 22069.65| 22106.21| -11028.82| 22057.65| 0.001| 1| 0.971|
## |insomnia | 7| 22070.63| 22113.29| -11028.32| 22056.63| 1.016| 1| 0.313|
## |worry.mc:insomnia | 8| 22069.01| 22117.77| -11026.50| 22053.01| 3.620| 1| 0.057|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. BMI.gmc : = 0.127
## - BMI.gmc vs. null model = 0.873
## - worry.mc = 0.383
## - w.nd.mc = 0.124
## - insomnia = 0.07
## - worry.mc:insomnia = 0.136
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2 |(Intercept) |58.86(0.49) |119.86 |58.86(0.49) |119.86 |58.35(0.70) |83.53 |
## |3 |BMI.gmc |-0.37(0.15) |-2.46 |-0.37(0.15) |-2.46 |-0.35(0.15) |-2.26 |
## |4 |worry.mc |-0.15(0.13) |-1.15 |-0.15(0.14) |-1.12 |0.11(0.19) |0.58 |
## |7 |w.nd.mc | | |-0.00(0.14) |-0.04 |-0.00(0.14) |-0.01 |
## |8 |insomnia [1] | | | | |1.00(0.99) |1.01 |
## |9 |worry.mc * insomnia [1] | | | | |-0.51(0.27) |-1.90 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.49(NA) | |4.49(NA) | |4.45(NA) | |
## |6 |SD (Observations) |2.60(NA) | |2.60(NA) | |2.60(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing light.p by mood
## ###########################################
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00421796 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00421796 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00421796 (tol = 0.002, component 1)
## Running GLMER analysis of light.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): light.p ~ (1|ID)
## - model M1: light.p ~ BMI.gmc + (1|ID)
## - model M2: light.p ~ BMI.gmc + mood.mc + (mood.mc|ID)
## - model M3: light.p ~ BMI.gmc + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M4: light.p ~ BMI.gmc + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M5: light.p ~ BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of light.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00421796 (tol = 0.002, component 1)
##
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 22070.82| 22089.10| -11032.41| 22064.82| NA| NA| NA|
## |BMI.gmc | 4| 22066.97| 22091.35| -11029.48| 22058.97| 5.852| 1| 0.016|
## |mood.mc | 7| 22070.26| 22112.92| -11028.13| 22056.26| 2.709| 3| 0.439|
## |m.nd.mc | 8| 22071.97| 22120.73| -11027.99| 22055.97| 0.288| 1| 0.592|
## |insomnia | 9| 22073.12| 22127.97| -11027.56| 22055.12| 0.852| 1| 0.356|
## |mood.mc:insomnia | 10| 22074.10| 22135.04| -11027.05| 22054.10| 1.024| 1| 0.312|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. BMI.gmc : = 0.127
## - BMI.gmc vs. null model = 0.873
## - mood.mc = 0.144
## - m.nd.mc = 0.058
## - insomnia = 0.031
## - mood.mc:insomnia = 0.019
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:----------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2 |(Intercept) |58.86(0.49) |119.86 |58.86(0.49) |119.87 |58.36(0.70) |83.57 |
## |3 |BMI.gmc |-0.39(0.15) |-2.59 |-0.39(0.15) |-2.59 |-0.36(0.15) |-2.36 |
## |4 |mood.mc |0.01(0.16) |0.09 |0.01(0.16) |0.04 |0.17(0.22) |0.75 |
## |9 |m.nd.mc | | |0.07(0.14) |0.54 |0.08(0.14) |0.55 |
## |10 |insomnia [1] | | | | |0.98(0.99) |0.99 |
## |11 |mood.mc * insomnia [1] | | | | |-0.32(0.31) |-1.05 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.49(NA) | |4.49(NA) | |4.45(NA) | |
## |6 |SD (mood.mc) |0.63(NA) | |0.62(NA) | |0.56(NA) | |
## |8 |SD (Observations) |2.59(NA) | |2.59(NA) | |2.60(NA) | |
## |7 |Cor (Intercept~ID) |-0.18(NA) | |-0.18(NA) | |-0.15(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing light.p by PsyDist
## ###########################################
##
## Running GLMER analysis of light.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): light.p ~ (1|ID)
## - model M1: light.p ~ BMI.gmc + (1|ID)
## - model M2: light.p ~ BMI.gmc + PsyDist.mc + (PsyDist.mc|ID)
## - model M3: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M4: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M5: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of light.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 22070.82| 22089.10| -11032.41| 22064.82| NA| NA| NA|
## |BMI.gmc | 4| 22066.97| 22091.35| -11029.48| 22058.97| 5.852| 1| 0.016|
## |PsyDist.mc | 7| 22069.39| 22112.05| -11027.69| 22055.39| 3.581| 3| 0.310|
## |P.nd.mc | 8| 22071.17| 22119.93| -11027.59| 22055.17| 0.215| 1| 0.643|
## |insomnia | 9| 22072.21| 22127.06| -11027.10| 22054.21| 0.962| 1| 0.327|
## |PsyDist.mc:insomnia | 10| 22073.73| 22134.67| -11026.86| 22053.73| 0.481| 1| 0.488|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. BMI.gmc : = 0.127
## - BMI.gmc vs. null model = 0.873
## - PsyDist.mc = 0.207
## - P.nd.mc = 0.078
## - insomnia = 0.044
## - PsyDist.mc:insomnia = 0.02
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2 |(Intercept) |58.86(0.49) |119.89 |58.86(0.49) |119.89 |58.35(0.70) |83.54 |
## |3 |BMI.gmc |-0.38(0.15) |-2.53 |-0.38(0.15) |-2.53 |-0.35(0.15) |-2.30 |
## |4 |PsyDist.mc |-0.10(0.20) |-0.51 |-0.12(0.20) |-0.61 |0.02(0.29) |0.05 |
## |9 |P.nd.mc | | |0.08(0.18) |0.46 |0.09(0.18) |0.47 |
## |10 |insomnia [1] | | | | |1.00(0.99) |1.01 |
## |11 |PsyDist.mc * insomnia [1] | | | | |-0.28(0.39) |-0.70 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.49(NA) | |4.49(NA) | |4.45(NA) | |
## |6 |SD (PsyDist.mc) |0.81(NA) | |0.82(NA) | |0.78(NA) | |
## |8 |SD (Observations) |2.59(NA) | |2.59(NA) | |2.59(NA) | |
## |7 |Cor (Intercept~ID) |-0.07(NA) | |-0.07(NA) | |-0.04(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing light.p by fs.w
## ###########################################
##
## Running GLMER analysis of light.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Grand-mean-centering BMI
##
## Model specification:
## - model M0 (null): light.p ~ (1|ID)
## - model M1: light.p ~ BMI.gmc + (1|ID)
## - model M2: light.p ~ BMI.gmc + fs.w + (fs.w|ID)
## - model M3: light.p ~ BMI.gmc + fs.w + f.nd + (fs.w|ID)
## - model M4: light.p ~ BMI.gmc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M5: light.p ~ BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of light.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 22070.82| 22089.10| -11032.41| 22064.82| NA| NA| NA|
## |BMI.gmc | 4| 22066.97| 22091.35| -11029.48| 22058.97| 5.852| 1| 0.016|
## |fs.w | 7| 22069.20| 22111.86| -11027.60| 22055.20| 3.766| 3| 0.288|
## |f.nd | 8| 22071.04| 22119.80| -11027.52| 22055.04| 0.157| 1| 0.692|
## |insomnia | 9| 22072.09| 22126.94| -11027.05| 22054.09| 0.950| 1| 0.330|
## |fs.w:insomnia | 10| 22073.17| 22134.11| -11026.58| 22053.17| 0.924| 1| 0.336|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. BMI.gmc : = 0.127
## - BMI.gmc vs. null model = 0.873
## - fs.w = 0.222
## - f.nd = 0.081
## - insomnia = 0.046
## - fs.w:insomnia = 0.026
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2 |(Intercept) |58.86(0.49) |119.91 |58.86(0.49) |119.90 |58.36(0.70) |83.54 |
## |3 |BMI.gmc |-0.38(0.15) |-2.53 |-0.38(0.15) |-2.53 |-0.35(0.15) |-2.30 |
## |4 |fs.w |-0.09(0.17) |-0.52 |-0.10(0.17) |-0.60 |0.06(0.25) |0.25 |
## |9 |f.nd | | |0.06(0.15) |0.40 |0.06(0.15) |0.41 |
## |10 |insomnia [1] | | | | |1.00(0.99) |1.01 |
## |11 |fs.w * insomnia [1] | | | | |-0.33(0.33) |-0.98 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.49(NA) | |4.49(NA) | |4.45(NA) | |
## |6 |SD (fs.w) |0.71(NA) | |0.71(NA) | |0.66(NA) | |
## |8 |SD (Observations) |2.59(NA) | |2.59(NA) | |2.59(NA) | |
## |7 |Cor (Intercept~ID) |-0.07(NA) | |-0.07(NA) | |-0.03(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of both distributions) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
BMI is the only predictor associated with a significant LRT, and with stronger evidence in terms of Aw
coherently, BMI is the only predictor showing a substantial relationship with light.p
In section 5.1, deep.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SOL.num (higher deep.p for later SO than usual). Note that no random slopes are included due to convergence problems
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing deep.p by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- "(1|ID)" # no random slopes due to convergence problems
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",
fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing deep.p by stress
## ###########################################
##
## Running GLMER analysis of deep.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): deep.p ~ (1|ID)
## - model M1: deep.p ~ SO.num.mc + (1|ID)
## - model M2: deep.p ~ SO.num.mc + stress.mc + (1|ID)
## - model M3: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + (1|ID)
## - model M4: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + (1|ID)
## - model M5: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
##
## Fitting GLMER models of deep.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc stress.mc s.nd.mc insomnia
## 1.004902 2.192285 1.065317 1.000000
## stress.mc:insomnia
## 2.148788
##
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 19491.00| 19509.28| -9742.498| 19485.00| NA| NA| NA|
## |SO.num.mc | 4| 19482.72| 19507.10| -9737.362| 19474.72| 10.271| 1| 0.001|
## |stress.mc | 5| 19483.67| 19514.15| -9736.836| 19473.67| 1.052| 1| 0.305|
## |s.nd.mc | 6| 19485.51| 19522.08| -9736.755| 19473.51| 0.162| 1| 0.687|
## |insomnia | 7| 19487.14| 19529.80| -9736.568| 19473.14| 0.374| 1| 0.541|
## |stress.mc:insomnia | 8| 19487.46| 19536.22| -9735.730| 19471.46| 1.677| 1| 0.195|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.016
## - SO.num.mc vs. null model = 0.984
## - stress.mc = 0.38
## - s.nd.mc = 0.132
## - insomnia = 0.055
## - stress.mc:insomnia = 0.045
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3 |SO.num.mc |0.24(0.07) |3.25 |0.24(0.07) |3.27 |0.24(0.07) |3.26 |
## |4 |stress.mc |0.09(0.09) |1.03 |0.08(0.09) |0.90 |0.20(0.13) |1.56 |
## |7 |s.nd.mc | | |0.04(0.09) |0.40 |0.04(0.09) |0.44 |
## |8 |insomnia [1] | | | | |-0.35(0.58) |-0.61 |
## |9 |stress.mc * insomnia [1] | | | | |-0.23(0.17) |-1.30 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |2.60(NA) | |2.60(NA) | |2.60(NA) | |
## |6 |SD (Observations) |2.14(NA) | |2.14(NA) | |2.14(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing deep.p by worry
## ###########################################
##
## Running GLMER analysis of deep.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): deep.p ~ (1|ID)
## - model M1: deep.p ~ SO.num.mc + (1|ID)
## - model M2: deep.p ~ SO.num.mc + worry.mc + (1|ID)
## - model M3: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + (1|ID)
## - model M4: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + (1|ID)
## - model M5: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
##
## Fitting GLMER models of deep.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 19491.00| 19509.28| -9742.498| 19485.00| NA| NA| NA|
## |SO.num.mc | 4| 19482.72| 19507.10| -9737.362| 19474.72| 10.271| 1| 0.001|
## |worry.mc | 5| 19482.98| 19513.45| -9736.490| 19472.98| 1.745| 1| 0.186|
## |w.nd.mc | 6| 19484.37| 19520.93| -9736.183| 19472.37| 0.613| 1| 0.434|
## |insomnia | 7| 19485.99| 19528.65| -9735.996| 19471.99| 0.374| 1| 0.541|
## |worry.mc:insomnia | 8| 19487.60| 19536.36| -9735.802| 19471.60| 0.388| 1| 0.533|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.016
## - SO.num.mc vs. null model = 0.984
## - worry.mc = 0.464
## - w.nd.mc = 0.188
## - insomnia = 0.077
## - worry.mc:insomnia = 0.033
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3 |SO.num.mc |0.24(0.07) |3.30 |0.24(0.07) |3.27 |0.24(0.07) |3.28 |
## |4 |worry.mc |0.12(0.09) |1.32 |0.13(0.09) |1.45 |0.08(0.13) |0.58 |
## |7 |w.nd.mc | | |-0.07(0.09) |-0.78 |-0.07(0.09) |-0.79 |
## |8 |insomnia [1] | | | | |-0.35(0.58) |-0.61 |
## |9 |worry.mc * insomnia [1] | | | | |0.11(0.18) |0.62 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |2.60(NA) | |2.60(NA) | |2.60(NA) | |
## |6 |SD (Observations) |2.14(NA) | |2.14(NA) | |2.14(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing deep.p by mood
## ###########################################
##
## Running GLMER analysis of deep.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): deep.p ~ (1|ID)
## - model M1: deep.p ~ SO.num.mc + (1|ID)
## - model M2: deep.p ~ SO.num.mc + mood.mc + (1|ID)
## - model M3: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + (1|ID)
## - model M4: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M5: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of deep.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 19491.00| 19509.28| -9742.498| 19485.00| NA| NA| NA|
## |SO.num.mc | 4| 19482.72| 19507.10| -9737.362| 19474.72| 10.271| 1| 0.001|
## |mood.mc | 5| 19484.23| 19514.70| -9737.116| 19474.23| 0.492| 1| 0.483|
## |m.nd.mc | 6| 19486.12| 19522.69| -9737.063| 19474.12| 0.107| 1| 0.743|
## |insomnia | 7| 19487.75| 19530.41| -9736.876| 19473.75| 0.374| 1| 0.541|
## |mood.mc:insomnia | 8| 19488.52| 19537.28| -9736.262| 19472.52| 1.228| 1| 0.268|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.016
## - SO.num.mc vs. null model = 0.984
## - mood.mc = 0.317
## - m.nd.mc = 0.109
## - insomnia = 0.046
## - mood.mc:insomnia = 0.031
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3 |SO.num.mc |0.24(0.07) |3.25 |0.24(0.07) |3.25 |0.24(0.07) |3.26 |
## |4 |mood.mc |0.07(0.09) |0.70 |0.07(0.09) |0.73 |-0.04(0.14) |-0.31 |
## |7 |m.nd.mc | | |-0.03(0.09) |-0.33 |-0.03(0.09) |-0.33 |
## |8 |insomnia [1] | | | | |-0.35(0.58) |-0.61 |
## |9 |mood.mc * insomnia [1] | | | | |0.21(0.19) |1.11 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |2.60(NA) | |2.60(NA) | |2.60(NA) | |
## |6 |SD (Observations) |2.14(NA) | |2.14(NA) | |2.14(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing deep.p by PsyDist
## ###########################################
##
## Running GLMER analysis of deep.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): deep.p ~ (1|ID)
## - model M1: deep.p ~ SO.num.mc + (1|ID)
## - model M2: deep.p ~ SO.num.mc + PsyDist.mc + (1|ID)
## - model M3: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + (1|ID)
## - model M4: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
## - model M5: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
##
## Fitting GLMER models of deep.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 19491.00| 19509.28| -9742.498| 19485.00| NA| NA| NA|
## |SO.num.mc | 4| 19482.72| 19507.10| -9737.362| 19474.72| 10.271| 1| 0.001|
## |PsyDist.mc | 5| 19483.06| 19513.53| -9736.528| 19473.06| 1.669| 1| 0.196|
## |P.nd.mc | 6| 19484.89| 19521.46| -9736.444| 19472.89| 0.167| 1| 0.683|
## |insomnia | 7| 19486.51| 19529.18| -9736.258| 19472.51| 0.373| 1| 0.541|
## |PsyDist.mc:insomnia | 8| 19488.51| 19537.26| -9736.254| 19472.51| 0.007| 1| 0.935|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.016
## - SO.num.mc vs. null model = 0.984
## - PsyDist.mc = 0.455
## - P.nd.mc = 0.154
## - insomnia = 0.064
## - PsyDist.mc:insomnia = 0.023
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |19.78(0.29) |68.48 |19.78(0.29) |68.47 |19.95(0.41) |48.78 |
## |3 |SO.num.mc |0.24(0.07) |3.31 |0.24(0.07) |3.29 |0.24(0.07) |3.30 |
## |4 |PsyDist.mc |0.15(0.12) |1.29 |0.16(0.12) |1.35 |0.15(0.18) |0.88 |
## |7 |P.nd.mc | | |-0.05(0.12) |-0.41 |-0.05(0.12) |-0.41 |
## |8 |insomnia [1] | | | | |-0.35(0.58) |-0.61 |
## |9 |PsyDist.mc * insomnia [1] | | | | |0.02(0.23) |0.08 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |2.61(NA) | |2.61(NA) | |2.60(NA) | |
## |6 |SD (Observations) |2.14(NA) | |2.14(NA) | |2.14(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing deep.p by fs.w
## ###########################################
##
## Running GLMER analysis of deep.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): deep.p ~ (1|ID)
## - model M1: deep.p ~ SO.num.mc + (1|ID)
## - model M2: deep.p ~ SO.num.mc + fs.w + (1|ID)
## - model M3: deep.p ~ SO.num.mc + fs.w + f.nd + (1|ID)
## - model M4: deep.p ~ SO.num.mc + fs.w + f.nd + insomnia + (1|ID)
## - model M5: deep.p ~ SO.num.mc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
##
## Fitting GLMER models of deep.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 19491.00| 19509.28| -9742.498| 19485.00| NA| NA| NA|
## |SO.num.mc | 4| 19482.72| 19507.10| -9737.362| 19474.72| 10.271| 1| 0.001|
## |fs.w | 5| 19483.02| 19513.49| -9736.509| 19473.02| 1.707| 1| 0.191|
## |f.nd | 6| 19484.74| 19521.30| -9736.368| 19472.74| 0.282| 1| 0.596|
## |insomnia | 7| 19486.36| 19529.02| -9736.180| 19472.36| 0.375| 1| 0.540|
## |fs.w:insomnia | 8| 19488.25| 19537.01| -9736.126| 19472.25| 0.107| 1| 0.743|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.016
## - SO.num.mc vs. null model = 0.984
## - fs.w = 0.46
## - f.nd = 0.163
## - insomnia = 0.067
## - fs.w:insomnia = 0.026
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |19.78(0.29) |68.47 |19.77(0.29) |68.47 |19.95(0.41) |48.78 |
## |3 |SO.num.mc |0.24(0.07) |3.31 |0.24(0.07) |3.30 |0.24(0.07) |3.30 |
## |4 |fs.w |0.13(0.10) |1.31 |0.14(0.10) |1.40 |0.11(0.15) |0.73 |
## |7 |f.nd | | |-0.05(0.10) |-0.53 |-0.06(0.10) |-0.54 |
## |8 |insomnia [1] | | | | |-0.35(0.58) |-0.61 |
## |9 |fs.w * insomnia [1] | | | | |0.07(0.20) |0.33 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |2.61(NA) | |2.61(NA) | |2.60(NA) | |
## |6 |SD (Observations) |2.14(NA) | |2.14(NA) | |2.14(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term
SO.num is the only predictor associated with a significant LRT, and with stronger evidence in terms of Aw
coherently, SO.num is the only predictor showing a substantial relationship with deep.p
In section 5.1, rem.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SOL.num (lower rem.p for later than usual SO). Note that the random slope for stress and PsyDist is not included due to convergence problems.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing rem.p by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("stress","PsyDist")){ ran.eff <- "(1|ID)" } # removing random slope for stress to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing rem.p by stress
## ###########################################
##
## Running GLMER analysis of rem.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): rem.p ~ (1|ID)
## - model M1: rem.p ~ SO.num.mc + (1|ID)
## - model M2: rem.p ~ SO.num.mc + stress.mc + (1|ID)
## - model M3: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + (1|ID)
## - model M4: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + (1|ID)
## - model M5: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
##
## Fitting GLMER models of rem.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc stress.mc s.nd.mc insomnia
## 1.004902 2.192285 1.065317 1.000000
## stress.mc:insomnia
## 2.148788
##
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 19770.98| 19789.26| -9882.488| 19764.98| NA| NA| NA|
## |SO.num.mc | 4| 19763.24| 19787.62| -9877.621| 19755.24| 9.735| 1| 0.002|
## |stress.mc | 5| 19765.11| 19795.58| -9877.553| 19755.11| 0.135| 1| 0.714|
## |s.nd.mc | 6| 19766.60| 19803.16| -9877.298| 19754.60| 0.511| 1| 0.475|
## |insomnia | 7| 19767.25| 19809.91| -9876.625| 19753.25| 1.347| 1| 0.246|
## |stress.mc:insomnia | 8| 19769.22| 19817.97| -9876.608| 19753.22| 0.034| 1| 0.854|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - stress.mc = 0.278
## - s.nd.mc = 0.117
## - insomnia = 0.078
## - stress.mc:insomnia = 0.028
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |21.36(0.44) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.72 |
## |3 |SO.num.mc |-0.23(0.07) |-3.10 |-0.23(0.07) |-3.13 |-0.23(0.08) |-3.13 |
## |4 |stress.mc |0.03(0.09) |0.37 |0.05(0.09) |0.53 |0.03(0.13) |0.23 |
## |7 |s.nd.mc | | |-0.07(0.09) |-0.71 |-0.07(0.09) |-0.72 |
## |8 |insomnia [1] | | | | |-1.01(0.86) |-1.17 |
## |9 |stress.mc * insomnia [1] | | | | |0.03(0.18) |0.18 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.04(NA) | |4.04(NA) | |4.00(NA) | |
## |6 |SD (Observations) |2.17(NA) | |2.17(NA) | |2.17(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing rem.p by worry
## ###########################################
##
## Running GLMER analysis of rem.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): rem.p ~ (1|ID)
## - model M1: rem.p ~ SO.num.mc + (1|ID)
## - model M2: rem.p ~ SO.num.mc + worry.mc + (worry.mc|ID)
## - model M3: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M4: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M5: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of rem.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 19770.98| 19789.26| -9882.488| 19764.98| NA| NA| NA|
## |SO.num.mc | 4| 19763.24| 19787.62| -9877.621| 19755.24| 9.735| 1| 0.002|
## |worry.mc | 7| 19768.05| 19810.71| -9877.027| 19754.05| 1.189| 3| 0.756|
## |w.nd.mc | 8| 19769.37| 19818.13| -9876.685| 19753.37| 0.682| 1| 0.409|
## |insomnia | 9| 19770.19| 19825.03| -9876.093| 19752.19| 1.185| 1| 0.276|
## |worry.mc:insomnia | 10| 19768.49| 19829.43| -9874.244| 19748.49| 3.698| 1| 0.054|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - worry.mc = 0.081
## - w.nd.mc = 0.04
## - insomnia = 0.026
## - worry.mc:insomnia = 0.058
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |21.36(0.44) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.72 |
## |3 |SO.num.mc |-0.23(0.08) |-3.04 |-0.23(0.08) |-3.02 |-0.23(0.08) |-3.03 |
## |4 |worry.mc |0.02(0.10) |0.20 |0.00(0.10) |0.04 |-0.19(0.14) |-1.34 |
## |9 |w.nd.mc | | |0.08(0.10) |0.83 |0.08(0.10) |0.79 |
## |10 |insomnia [1] | | | | |-1.01(0.86) |-1.17 |
## |11 |worry.mc * insomnia [1] | | | | |0.38(0.19) |2.02 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.04(NA) | |4.04(NA) | |4.00(NA) | |
## |6 |SD (worry.mc) |0.31(NA) | |0.31(NA) | |0.18(NA) | |
## |8 |SD (Observations) |2.17(NA) | |2.17(NA) | |2.17(NA) | |
## |7 |Cor (Intercept~ID) |-0.16(NA) | |-0.17(NA) | |-0.10(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing rem.p by mood
## ###########################################
##
## Running GLMER analysis of rem.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): rem.p ~ (1|ID)
## - model M1: rem.p ~ SO.num.mc + (1|ID)
## - model M2: rem.p ~ SO.num.mc + mood.mc + (mood.mc|ID)
## - model M3: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M4: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M5: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of rem.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 19770.98| 19789.26| -9882.488| 19764.98| NA| NA| NA|
## |SO.num.mc | 4| 19763.24| 19787.62| -9877.621| 19755.24| 9.735| 1| 0.002|
## |mood.mc | 7| 19767.42| 19810.08| -9876.711| 19753.42| 1.820| 3| 0.610|
## |m.nd.mc | 8| 19769.18| 19817.94| -9876.592| 19753.18| 0.237| 1| 0.626|
## |insomnia | 9| 19769.86| 19824.71| -9875.931| 19751.86| 1.323| 1| 0.250|
## |mood.mc:insomnia | 10| 19771.32| 19832.26| -9875.659| 19751.32| 0.543| 1| 0.461|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - mood.mc = 0.108
## - m.nd.mc = 0.043
## - insomnia = 0.03
## - mood.mc:insomnia = 0.014
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |21.36(0.44) |49.10 |21.36(0.44) |49.10 |21.87(0.61) |35.71 |
## |3 |SO.num.mc |-0.23(0.08) |-3.07 |-0.23(0.08) |-3.07 |-0.23(0.08) |-3.07 |
## |4 |mood.mc |-0.05(0.11) |-0.50 |-0.05(0.11) |-0.45 |-0.13(0.15) |-0.85 |
## |9 |m.nd.mc | | |-0.05(0.10) |-0.49 |-0.05(0.10) |-0.49 |
## |10 |insomnia [1] | | | | |-1.01(0.86) |-1.17 |
## |11 |mood.mc * insomnia [1] | | | | |0.16(0.21) |0.74 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.04(NA) | |4.04(NA) | |4.00(NA) | |
## |6 |SD (mood.mc) |0.39(NA) | |0.39(NA) | |0.37(NA) | |
## |8 |SD (Observations) |2.17(NA) | |2.17(NA) | |2.17(NA) | |
## |7 |Cor (Intercept~ID) |-0.05(NA) | |-0.05(NA) | |-0.02(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing rem.p by PsyDist
## ###########################################
##
## Running GLMER analysis of rem.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): rem.p ~ (1|ID)
## - model M1: rem.p ~ SO.num.mc + (1|ID)
## - model M2: rem.p ~ SO.num.mc + PsyDist.mc + (1|ID)
## - model M3: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + (1|ID)
## - model M4: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
## - model M5: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
##
## Fitting GLMER models of rem.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 19770.98| 19789.26| -9882.488| 19764.98| NA| NA| NA|
## |SO.num.mc | 4| 19763.24| 19787.62| -9877.621| 19755.24| 9.735| 1| 0.002|
## |PsyDist.mc | 5| 19765.21| 19795.68| -9877.603| 19755.21| 0.036| 1| 0.849|
## |P.nd.mc | 6| 19767.17| 19803.73| -9877.583| 19755.17| 0.039| 1| 0.844|
## |insomnia | 7| 19767.82| 19810.48| -9876.909| 19753.82| 1.348| 1| 0.246|
## |PsyDist.mc:insomnia | 8| 19768.02| 19816.78| -9876.012| 19752.02| 1.795| 1| 0.180|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - PsyDist.mc = 0.268
## - P.nd.mc = 0.091
## - insomnia = 0.062
## - PsyDist.mc:insomnia = 0.053
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |21.36(0.43) |49.11 |21.36(0.43) |49.11 |21.87(0.61) |35.71 |
## |3 |SO.num.mc |-0.23(0.08) |-3.09 |-0.23(0.08) |-3.10 |-0.23(0.08) |-3.08 |
## |4 |PsyDist.mc |0.02(0.12) |0.19 |0.03(0.13) |0.24 |-0.15(0.18) |-0.80 |
## |7 |P.nd.mc | | |-0.02(0.12) |-0.20 |-0.03(0.12) |-0.22 |
## |8 |insomnia [1] | | | | |-1.01(0.86) |-1.17 |
## |9 |PsyDist.mc * insomnia [1] | | | | |0.32(0.24) |1.34 |
## |10 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |11 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.04(NA) | |4.04(NA) | |4.00(NA) | |
## |6 |SD (Observations) |2.17(NA) | |2.17(NA) | |2.17(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing rem.p by fs.w
## ###########################################
##
## Running GLMER analysis of rem.p ...
##
## Preparing data...
## - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
## and 2 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): rem.p ~ (1|ID)
## - model M1: rem.p ~ SO.num.mc + (1|ID)
## - model M2: rem.p ~ SO.num.mc + fs.w + (fs.w|ID)
## - model M3: rem.p ~ SO.num.mc + fs.w + f.nd + (fs.w|ID)
## - model M4: rem.p ~ SO.num.mc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M5: rem.p ~ SO.num.mc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of rem.p on 3276 observations from 91 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: SO.num.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Null model | 3| 19770.98| 19789.26| -9882.488| 19764.98| NA| NA| NA|
## |SO.num.mc | 4| 19763.24| 19787.62| -9877.621| 19755.24| 9.735| 1| 0.002|
## |fs.w | 7| 19766.43| 19809.09| -9876.215| 19752.43| 2.811| 3| 0.422|
## |f.nd | 8| 19768.43| 19817.19| -9876.215| 19752.43| 0.001| 1| 0.977|
## |insomnia | 9| 19769.26| 19824.11| -9875.632| 19751.26| 1.167| 1| 0.280|
## |fs.w:insomnia | 10| 19769.79| 19830.73| -9874.894| 19749.79| 1.476| 1| 0.224|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.02
## - SO.num.mc vs. null model = 0.98
## - fs.w = 0.166
## - f.nd = 0.058
## - insomnia = 0.037
## - fs.w:insomnia = 0.027
## Selected model: SO.num.mc
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |21.36(0.43) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.71 |
## |3 |SO.num.mc |-0.22(0.08) |-2.98 |-0.22(0.08) |-2.98 |-0.22(0.08) |-2.98 |
## |4 |fs.w |-0.01(0.12) |-0.11 |-0.01(0.12) |-0.10 |-0.16(0.17) |-0.93 |
## |9 |f.nd | | |-0.00(0.11) |-0.03 |-0.00(0.11) |-0.04 |
## |10 |insomnia [1] | | | | |-1.01(0.86) |-1.17 |
## |11 |fs.w * insomnia [1] | | | | |0.28(0.23) |1.24 |
## |12 |N |91 ID |91 ID |91 ID |NA |NA |NA |
## |13 |Observations |3276 |3276 |3276 |NA |NA |NA |
## |5 |SD (Intercept) |4.04(NA) | |4.04(NA) | |4.00(NA) | |
## |6 |SD (fs.w) |0.45(NA) | |0.45(NA) | |0.40(NA) | |
## |8 |SD (Observations) |2.17(NA) | |2.17(NA) | |2.17(NA) | |
## |7 |Cor (Intercept~ID) |-0.20(NA) | |-0.20(NA) | |-0.17(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
SO.num is the only predictor associated with a significant LRT, and with stronger evidence in terms of Aw
coherently, SO.num is the only predictor showing a substantial relationship with rem.p
s.timing variables are modeled by considering the subset of complete s.timing and dailyDiary data, whereas dailyAct data are ignored since none of the s.archit variables was substantially predicted by TotalSteps1000 (i.e., it negatively predicted SO.num but the relationship was small and not supported by the Aw and the LRT). sex is excluded as well, for parsimony, and since it only predicted small differences in SO.num, but not in diary ratings.
s.timing <- c("SO.num","WakeUp.num")
In section 5.1, SO.num was modeled by assuming a normal distribution for residuals, and it was substantially predicted by weekday.sleep (later SO.num during weekend), TotalSteps (earlier SO.num in days with more steps than usual), BMI (earlier SO.num for participants with higher BMI), and sex (later SO.num for boys compared to girls). Here, we do not include sex and TotalSteps1000 for parsimony, and because the latter was not selected based on the LRT or the Aw, and showed the less substantial effect in section 5.1.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SO.num by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",
fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing SO.num by stress
## ###########################################
##
## Running GLMER analysis of SO.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): SO.num ~ (1|ID)
## - model M1: SO.num ~ weekday.sleep + (1|ID)
## - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + (stress.mc|ID)
## - model M4: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of SO.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## weekday.sleep BMI.gmc stress.mc s.nd.mc
## 1.019806 1.030042 2.064217 1.037407
## insomnia stress.mc:insomnia
## 1.035872 2.053621
##
##
## - Running likelihood ratio test:
## Selected model: stress.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 12083.59| 12102.32| -6038.797| 12077.59| NA| NA| NA|
## |weekday.sleep | 4| 11962.20| 11987.17| -5977.098| 11954.20| 123.399| 1| 0.000|
## |BMI.gmc | 5| 11958.27| 11989.48| -5974.136| 11948.27| 5.924| 1| 0.015|
## |stress.mc | 8| 11909.83| 11959.77| -5946.917| 11893.83| 54.439| 3| 0.000|
## |s.nd.mc | 9| 11908.78| 11964.96| -5945.392| 11890.78| 3.049| 1| 0.081|
## |insomnia | 10| 11910.70| 11973.12| -5945.348| 11890.70| 0.087| 1| 0.768|
## |stress.mc:insomnia | 11| 11912.69| 11981.36| -5945.348| 11890.69| 0.001| 1| 0.969|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.877
## - stress.mc = 1
## - s.nd.mc = 0.628
## - insomnia = 0.194
## - stress.mc:insomnia = 0.067
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |0.49(0.11) |4.40 |0.50(0.11) |4.43 |0.53(0.16) |3.32 |
## |3 |weekday.sleep [weekend] |0.44(0.04) |10.70 |0.43(0.04) |10.41 |0.43(0.04) |10.41 |
## |4 |BMI.gmc |-0.08(0.03) |-2.43 |-0.08(0.03) |-2.44 |-0.09(0.04) |-2.45 |
## |5 |stress.mc |-0.06(0.03) |-1.79 |-0.05(0.03) |-1.53 |-0.05(0.05) |-1.05 |
## |10 |s.nd.mc | | |-0.04(0.02) |-1.75 |-0.04(0.02) |-1.74 |
## |11 |insomnia [1] | | | | |-0.07(0.23) |-0.29 |
## |12 |stress.mc * insomnia [1] | | | | |-0.00(0.06) |-0.04 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |7 |SD (stress.mc) |0.22(NA) | |0.22(NA) | |0.22(NA) | |
## |9 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |8 |Cor (Intercept~ID) |-0.11(NA) | |-0.11(NA) | |-0.11(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing SO.num by worry
## ###########################################
##
## Running GLMER analysis of SO.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): SO.num ~ (1|ID)
## - model M1: SO.num ~ weekday.sleep + (1|ID)
## - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + (worry.mc|ID)
## - model M4: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of SO.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: worry.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 12083.59| 12102.32| -6038.797| 12077.59| NA| NA| NA|
## |weekday.sleep | 4| 11962.20| 11987.17| -5977.098| 11954.20| 123.399| 1| 0.000|
## |BMI.gmc | 5| 11958.27| 11989.48| -5974.136| 11948.27| 5.924| 1| 0.015|
## |worry.mc | 8| 11937.46| 11987.40| -5960.732| 11921.46| 26.808| 3| 0.000|
## |w.nd.mc | 9| 11938.08| 11994.26| -5960.039| 11920.08| 1.386| 1| 0.239|
## |insomnia | 10| 11939.98| 12002.41| -5959.992| 11919.98| 0.094| 1| 0.759|
## |worry.mc:insomnia | 11| 11941.98| 12010.65| -5959.992| 11919.98| 0.000| 1| 0.990|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.877
## - worry.mc = 1
## - w.nd.mc = 0.424
## - insomnia = 0.14
## - worry.mc:insomnia = 0.049
## Selected model: worry.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |0.49(0.11) |4.38 |0.49(0.11) |4.38 |0.53(0.16) |3.30 |
## |3 |weekday.sleep [weekend] |0.45(0.04) |10.84 |0.44(0.04) |10.81 |0.44(0.04) |10.81 |
## |4 |BMI.gmc |-0.09(0.03) |-2.50 |-0.09(0.03) |-2.50 |-0.09(0.04) |-2.51 |
## |5 |worry.mc |-0.06(0.03) |-2.07 |-0.05(0.03) |-1.88 |-0.05(0.04) |-1.29 |
## |10 |w.nd.mc | | |-0.02(0.02) |-1.18 |-0.02(0.02) |-1.18 |
## |11 |insomnia [1] | | | | |-0.07(0.23) |-0.30 |
## |12 |worry.mc * insomnia [1] | | | | |-0.00(0.06) |-0.01 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |7 |SD (worry.mc) |0.16(NA) | |0.16(NA) | |0.16(NA) | |
## |9 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |8 |Cor (Intercept~ID) |-0.15(NA) | |-0.15(NA) | |-0.15(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing SO.num by mood
## ###########################################
##
## Running GLMER analysis of SO.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): SO.num ~ (1|ID)
## - model M1: SO.num ~ weekday.sleep + (1|ID)
## - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + (mood.mc|ID)
## - model M4: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M5: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M6: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of SO.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: mood.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 12083.59| 12102.32| -6038.797| 12077.59| NA| NA| NA|
## |weekday.sleep | 4| 11962.20| 11987.17| -5977.098| 11954.20| 123.399| 1| 0.000|
## |BMI.gmc | 5| 11958.27| 11989.48| -5974.136| 11948.27| 5.924| 1| 0.015|
## |mood.mc | 8| 11941.03| 11990.97| -5962.514| 11925.03| 23.245| 3| 0.000|
## |m.nd.mc | 9| 11942.97| 11999.15| -5962.486| 11924.97| 0.055| 1| 0.814|
## |insomnia | 10| 11944.89| 12007.31| -5962.446| 11924.89| 0.080| 1| 0.777|
## |mood.mc:insomnia | 11| 11946.25| 12014.91| -5962.122| 11924.25| 0.647| 1| 0.421|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.877
## - mood.mc = 1
## - m.nd.mc = 0.274
## - insomnia = 0.095
## - mood.mc:insomnia = 0.046
## Selected model: mood.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |0.49(0.11) |4.39 |0.49(0.11) |4.39 |0.53(0.16) |3.30 |
## |3 |weekday.sleep [weekend] |0.44(0.04) |10.77 |0.44(0.04) |10.76 |0.44(0.04) |10.76 |
## |4 |BMI.gmc |-0.09(0.03) |-2.53 |-0.09(0.03) |-2.53 |-0.09(0.04) |-2.53 |
## |5 |mood.mc |-0.09(0.03) |-3.44 |-0.09(0.03) |-3.40 |-0.06(0.04) |-1.70 |
## |10 |m.nd.mc | | |-0.00(0.02) |-0.24 |-0.00(0.02) |-0.22 |
## |11 |insomnia [1] | | | | |-0.07(0.23) |-0.31 |
## |12 |mood.mc * insomnia [1] | | | | |-0.04(0.05) |-0.81 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |7 |SD (mood.mc) |0.13(NA) | |0.13(NA) | |0.12(NA) | |
## |9 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |8 |Cor (Intercept~ID) |0.07(NA) | |0.07(NA) | |0.06(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing SO.num by PsyDist
## ###########################################
##
## Running GLMER analysis of SO.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): SO.num ~ (1|ID)
## - model M1: SO.num ~ weekday.sleep + (1|ID)
## - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of SO.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: PsyDist.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 12083.59| 12102.32| -6038.797| 12077.59| NA| NA| NA|
## |weekday.sleep | 4| 11962.20| 11987.17| -5977.098| 11954.20| 123.399| 1| 0.000|
## |BMI.gmc | 5| 11958.27| 11989.48| -5974.136| 11948.27| 5.924| 1| 0.015|
## |PsyDist.mc | 8| 11911.20| 11961.13| -5947.598| 11895.20| 53.076| 3| 0.000|
## |P.nd.mc | 9| 11912.79| 11968.97| -5947.394| 11894.79| 0.408| 1| 0.523|
## |insomnia | 10| 11914.70| 11977.12| -5947.348| 11894.70| 0.091| 1| 0.763|
## |PsyDist.mc:insomnia | 11| 11916.69| 11985.36| -5947.347| 11894.69| 0.002| 1| 0.968|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.877
## - PsyDist.mc = 1
## - P.nd.mc = 0.311
## - insomnia = 0.107
## - PsyDist.mc:insomnia = 0.038
## Selected model: PsyDist.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |0.50(0.11) |4.41 |0.50(0.11) |4.42 |0.53(0.16) |3.32 |
## |3 |weekday.sleep [weekend] |0.43(0.04) |10.47 |0.43(0.04) |10.41 |0.43(0.04) |10.41 |
## |4 |BMI.gmc |-0.08(0.03) |-2.43 |-0.08(0.03) |-2.43 |-0.09(0.04) |-2.45 |
## |5 |PsyDist.mc |-0.12(0.04) |-2.96 |-0.12(0.04) |-2.80 |-0.11(0.06) |-1.92 |
## |10 |P.nd.mc | | |-0.02(0.03) |-0.64 |-0.02(0.03) |-0.64 |
## |11 |insomnia [1] | | | | |-0.07(0.23) |-0.30 |
## |12 |PsyDist.mc * insomnia [1] | | | | |-0.00(0.08) |-0.04 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |7 |SD (PsyDist.mc) |0.27(NA) | |0.27(NA) | |0.27(NA) | |
## |9 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |8 |Cor (Intercept~ID) |-0.08(NA) | |-0.08(NA) | |-0.08(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing SO.num by fs.w
## ###########################################
##
## Running GLMER analysis of SO.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
##
## Model specification:
## - model M0 (null): SO.num ~ (1|ID)
## - model M1: SO.num ~ weekday.sleep + (1|ID)
## - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: SO.num ~ weekday.sleep + BMI.gmc + fs.w + (fs.w|ID)
## - model M4: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (fs.w|ID)
## - model M5: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of SO.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 12083.59| 12102.32| -6038.797| 12077.59| NA| NA| NA|
## |weekday.sleep | 4| 11962.20| 11987.17| -5977.098| 11954.20| 123.399| 1| 0.000|
## |BMI.gmc | 5| 11958.27| 11989.48| -5974.136| 11948.27| 5.924| 1| 0.015|
## |fs.w | 8| 11916.45| 11966.39| -5950.227| 11900.45| 47.817| 3| 0.000|
## |f.nd | 9| 11918.10| 11974.28| -5950.048| 11900.10| 0.359| 1| 0.549|
## |insomnia | 10| 11920.00| 11982.43| -5950.002| 11900.00| 0.093| 1| 0.761|
## |fs.w:insomnia | 11| 11922.00| 11990.67| -5950.001| 11900.00| 0.002| 1| 0.965|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.877
## - fs.w = 1
## - f.nd = 0.306
## - insomnia = 0.105
## - fs.w:insomnia = 0.037
## Selected model: fs.w
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |0.50(0.11) |4.41 |0.50(0.11) |4.42 |0.53(0.16) |3.32 |
## |3 |weekday.sleep [weekend] |0.43(0.04) |10.51 |0.43(0.04) |10.46 |0.43(0.04) |10.47 |
## |4 |BMI.gmc |-0.08(0.03) |-2.44 |-0.08(0.03) |-2.44 |-0.09(0.04) |-2.46 |
## |5 |fs.w |-0.10(0.03) |-2.98 |-0.10(0.03) |-2.83 |-0.10(0.05) |-1.93 |
## |10 |f.nd | | |-0.01(0.02) |-0.60 |-0.01(0.02) |-0.60 |
## |11 |insomnia [1] | | | | |-0.07(0.23) |-0.30 |
## |12 |fs.w * insomnia [1] | | | | |-0.00(0.07) |-0.04 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |6 |SD (Intercept) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |7 |SD (fs.w) |0.22(NA) | |0.22(NA) | |0.22(NA) | |
## |9 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |8 |Cor (Intercept~ID) |-0.08(NA) | |-0.08(NA) | |-0.08(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) residuals and (2) random effects are quite normally distributed, despite some marked deviations in the tails of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
weekday.sleep, BMI, and all raw and aggregate diary ratings (but not next day ratings) are associated with a significant LRT, whereas stronger evidence in terms of Aw is also shown by next day stress
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all raw and aggregate diary ratings with the only exception of stress; whereas neither next day ratings nor insomnia, or its interaction with diary ratings showed a substantial effect
In section 5.1, WakeUp.num was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (later WakeUp.num for later than usual SO), weekday.sleep (later WakeUp.num during weekend), and BMI (earlier WakeUp.num for participants with higher BMI). Note that the random slope for stress and mood is not included due to convergence problems.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WakeUp.num by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("stress","mood")){ ran.eff <- "(1|ID)" } # removing random slope for PsyDist to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results (considering M3 for stress, which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]=="stress",2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",
fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",
fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,
gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing WakeUp.num by stress
## ###########################################
##
## Running GLMER analysis of WakeUp.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): WakeUp.num ~ (1|ID)
## - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
## - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + (1|ID)
## - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID)
## - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
## - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
##
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc weekday.sleep BMI.gmc stress.mc
## 1.037432 1.056083 1.030432 2.306712
## s.nd.mc insomnia stress.mc:insomnia
## 1.077636 1.030455 2.259939
##
##
## - Running likelihood ratio test:
## Selected model: s.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 13060.81| 13079.54| -6527.407| 13054.81| NA| NA| NA|
## |SO.num.mc | 4| 12452.75| 12477.72| -6222.376| 12444.75| 610.061| 1| 0.000|
## |weekday.sleep | 5| 12013.34| 12044.55| -6001.668| 12003.34| 441.417| 1| 0.000|
## |BMI.gmc | 6| 12005.91| 12043.36| -5996.953| 11993.91| 9.430| 1| 0.002|
## |stress.mc | 7| 11974.48| 12018.18| -5980.241| 11960.48| 33.425| 1| 0.000|
## |s.nd.mc | 8| 11941.07| 11991.01| -5962.536| 11925.07| 35.410| 1| 0.000|
## |insomnia | 9| 11943.07| 11999.25| -5962.534| 11925.07| 0.003| 1| 0.955|
## |stress.mc:insomnia | 10| 11943.47| 12005.89| -5961.734| 11923.47| 1.599| 1| 0.206|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - BMI.gmc = 0.976
## - stress.mc = 1
## - s.nd.mc = 1
## - insomnia = 0.269
## - stress.mc:insomnia = 0.181
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |8.03(0.09) |87.47 |8.04(0.09) |87.54 |8.03(0.13) |61.50 |
## |3 |SO.num.mc |0.38(0.02) |22.75 |0.37(0.02) |22.68 |0.37(0.02) |22.70 |
## |4 |weekday.sleep [weekend] |0.89(0.04) |21.17 |0.86(0.04) |20.43 |0.86(0.04) |20.43 |
## |5 |BMI.gmc |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.09 |
## |6 |stress.mc |-0.12(0.02) |-5.79 |-0.09(0.02) |-4.33 |-0.12(0.03) |-3.87 |
## |9 |s.nd.mc | | |-0.12(0.02) |-5.96 |-0.12(0.02) |-6.00 |
## |10 |insomnia [1] | | | | |0.01(0.18) |0.06 |
## |11 |stress.mc * insomnia [1] | | | | |0.05(0.04) |1.26 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |7 |SD (Intercept) |0.85(NA) | |0.85(NA) | |0.85(NA) | |
## |8 |SD (Observations) |1.06(NA) | |1.06(NA) | |1.06(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing WakeUp.num by worry
## ###########################################
##
## Running GLMER analysis of WakeUp.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): WakeUp.num ~ (1|ID)
## - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
## - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + (worry.mc|ID)
## - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: worry.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 13060.81| 13079.54| -6527.407| 13054.81| NA| NA| NA|
## |SO.num.mc | 4| 12452.75| 12477.72| -6222.376| 12444.75| 610.061| 1| 0.000|
## |weekday.sleep | 5| 12013.34| 12044.55| -6001.668| 12003.34| 441.417| 1| 0.000|
## |BMI.gmc | 6| 12005.91| 12043.36| -5996.953| 11993.91| 9.430| 1| 0.002|
## |worry.mc | 9| 11941.02| 11997.20| -5961.511| 11923.02| 70.884| 3| 0.000|
## |w.nd.mc | 10| 11942.30| 12004.72| -5961.150| 11922.30| 0.721| 1| 0.396|
## |insomnia | 11| 11944.30| 12012.96| -5961.150| 11922.30| 0.001| 1| 0.974|
## |worry.mc:insomnia | 12| 11946.27| 12021.18| -5961.135| 11922.27| 0.029| 1| 0.864|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - BMI.gmc = 0.976
## - worry.mc = 1
## - w.nd.mc = 0.345
## - insomnia = 0.113
## - worry.mc:insomnia = 0.04
## Selected model: worry.mc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |8.03(0.09) |87.18 |8.03(0.09) |87.18 |8.03(0.13) |61.33 |
## |3 |SO.num.mc |0.37(0.02) |22.69 |0.37(0.02) |22.70 |0.37(0.02) |22.70 |
## |4 |weekday.sleep [weekend] |0.88(0.04) |20.89 |0.88(0.04) |20.91 |0.88(0.04) |20.90 |
## |5 |BMI.gmc |-0.10(0.03) |-3.76 |-0.10(0.03) |-3.75 |-0.10(0.03) |-3.69 |
## |6 |worry.mc |-0.15(0.03) |-5.32 |-0.15(0.03) |-5.37 |-0.16(0.04) |-3.86 |
## |11 |w.nd.mc | | |0.02(0.02) |0.85 |0.02(0.02) |0.85 |
## |12 |insomnia [1] | | | | |-0.00(0.19) |-0.02 |
## |13 |worry.mc * insomnia [1] | | | | |0.01(0.06) |0.17 |
## |14 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |15 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |7 |SD (Intercept) |0.85(NA) | |0.85(NA) | |0.85(NA) | |
## |8 |SD (worry.mc) |0.17(NA) | |0.17(NA) | |0.17(NA) | |
## |10 |SD (Observations) |1.06(NA) | |1.06(NA) | |1.06(NA) | |
## |9 |Cor (Intercept~ID) |-0.45(NA) | |-0.45(NA) | |-0.45(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing WakeUp.num by mood
## ###########################################
##
## Running GLMER analysis of WakeUp.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): WakeUp.num ~ (1|ID)
## - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
## - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + (1|ID)
## - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (1|ID)
## - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 13060.81| 13079.54| -6527.407| 13054.81| NA| NA| NA|
## |SO.num.mc | 4| 12452.75| 12477.72| -6222.376| 12444.75| 610.061| 1| 0.000|
## |weekday.sleep | 5| 12013.34| 12044.55| -6001.668| 12003.34| 441.417| 1| 0.000|
## |BMI.gmc | 6| 12005.91| 12043.36| -5996.953| 11993.91| 9.430| 1| 0.002|
## |mood.mc | 7| 12004.21| 12047.90| -5995.104| 11990.21| 3.698| 1| 0.054|
## |m.nd.mc | 8| 12005.99| 12055.93| -5994.996| 11989.99| 0.217| 1| 0.642|
## |insomnia | 9| 12007.99| 12064.17| -5994.995| 11989.99| 0.003| 1| 0.959|
## |mood.mc:insomnia | 10| 12009.87| 12072.29| -5994.935| 11989.87| 0.119| 1| 0.730|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - BMI.gmc = 0.976
## - mood.mc = 0.695
## - m.nd.mc = 0.222
## - insomnia = 0.076
## - mood.mc:insomnia = 0.029
## Selected model: mood.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |8.02(0.09) |87.44 |8.02(0.09) |87.44 |8.02(0.13) |61.44 |
## |3 |SO.num.mc |0.38(0.02) |22.79 |0.38(0.02) |22.79 |0.38(0.02) |22.78 |
## |4 |weekday.sleep [weekend] |0.91(0.04) |21.44 |0.91(0.04) |21.42 |0.91(0.04) |21.43 |
## |5 |BMI.gmc |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.09 |
## |6 |mood.mc |-0.04(0.02) |-1.92 |-0.04(0.02) |-1.86 |-0.03(0.03) |-0.95 |
## |9 |m.nd.mc | | |-0.01(0.02) |-0.47 |-0.01(0.02) |-0.46 |
## |10 |insomnia [1] | | | | |0.01(0.18) |0.05 |
## |11 |mood.mc * insomnia [1] | | | | |-0.01(0.04) |-0.35 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |7 |SD (Intercept) |0.85(NA) | |0.85(NA) | |0.85(NA) | |
## |8 |SD (Observations) |1.06(NA) | |1.06(NA) | |1.06(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing WakeUp.num by PsyDist
## ###########################################
##
## Running GLMER analysis of WakeUp.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): WakeUp.num ~ (1|ID)
## - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
## - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + (PsyDist.mc|ID)
## - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: PsyDist.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 13060.81| 13079.54| -6527.407| 13054.81| NA| NA| NA|
## |SO.num.mc | 4| 12452.75| 12477.72| -6222.376| 12444.75| 610.061| 1| 0.000|
## |weekday.sleep | 5| 12013.34| 12044.55| -6001.668| 12003.34| 441.417| 1| 0.000|
## |BMI.gmc | 6| 12005.91| 12043.36| -5996.953| 11993.91| 9.430| 1| 0.002|
## |PsyDist.mc | 9| 11938.62| 11994.80| -5960.308| 11920.62| 73.290| 3| 0.000|
## |P.nd.mc | 10| 11937.45| 11999.88| -5958.727| 11917.45| 3.162| 1| 0.075|
## |insomnia | 11| 11939.43| 12008.10| -5958.716| 11917.43| 0.022| 1| 0.882|
## |PsyDist.mc:insomnia | 12| 11941.36| 12016.27| -5958.681| 11917.36| 0.071| 1| 0.790|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - BMI.gmc = 0.976
## - PsyDist.mc = 1
## - P.nd.mc = 0.641
## - insomnia = 0.193
## - PsyDist.mc:insomnia = 0.068
## Selected model: P.nd.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |8.04(0.09) |86.98 |8.04(0.09) |86.98 |8.03(0.13) |61.21 |
## |3 |SO.num.mc |0.37(0.02) |22.40 |0.37(0.02) |22.39 |0.37(0.02) |22.39 |
## |4 |weekday.sleep [weekend] |0.88(0.04) |20.88 |0.87(0.04) |20.74 |0.87(0.04) |20.73 |
## |5 |BMI.gmc |-0.09(0.03) |-3.59 |-0.10(0.03) |-3.63 |-0.09(0.03) |-3.55 |
## |6 |PsyDist.mc |-0.19(0.04) |-4.99 |-0.18(0.04) |-4.59 |-0.19(0.06) |-3.37 |
## |11 |P.nd.mc | | |-0.05(0.03) |-1.78 |-0.05(0.03) |-1.79 |
## |12 |insomnia [1] | | | | |0.01(0.19) |0.03 |
## |13 |PsyDist.mc * insomnia [1] | | | | |0.02(0.08) |0.27 |
## |14 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |15 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |7 |SD (Intercept) |0.85(NA) | |0.85(NA) | |0.85(NA) | |
## |8 |SD (PsyDist.mc) |0.25(NA) | |0.25(NA) | |0.25(NA) | |
## |10 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |9 |Cor (Intercept~ID) |-0.60(NA) | |-0.60(NA) | |-0.60(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing WakeUp.num by fs.w
## ###########################################
##
## Running GLMER analysis of WakeUp.num ...
##
## Preparing data...
## - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): WakeUp.num ~ (1|ID)
## - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
## - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + (fs.w|ID)
## - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + (fs.w|ID)
## - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-------:|--:|----------:|
## |Null model | 3| 13060.81| 13079.54| -6527.407| 13054.81| NA| NA| NA|
## |SO.num.mc | 4| 12452.75| 12477.72| -6222.376| 12444.75| 610.061| 1| 0.000|
## |weekday.sleep | 5| 12013.34| 12044.55| -6001.668| 12003.34| 441.417| 1| 0.000|
## |BMI.gmc | 6| 12005.91| 12043.36| -5996.953| 11993.91| 9.430| 1| 0.002|
## |fs.w | 9| 11940.17| 11996.35| -5961.087| 11922.17| 71.731| 3| 0.000|
## |f.nd | 10| 11941.16| 12003.58| -5960.581| 11921.16| 1.014| 1| 0.314|
## |insomnia | 11| 11943.16| 12011.82| -5960.578| 11921.16| 0.005| 1| 0.943|
## |fs.w:insomnia | 12| 11945.14| 12020.04| -5960.568| 11921.14| 0.021| 1| 0.886|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0
## - SO.num.mc vs. null model = 1
## - weekday.sleep = 1
## - BMI.gmc = 0.976
## - fs.w = 1
## - f.nd = 0.379
## - insomnia = 0.123
## - fs.w:insomnia = 0.044
## Selected model: fs.w
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |8.04(0.09) |86.91 |8.04(0.09) |86.91 |8.03(0.13) |61.16 |
## |3 |SO.num.mc |0.37(0.02) |22.43 |0.37(0.02) |22.42 |0.37(0.02) |22.42 |
## |4 |weekday.sleep [weekend] |0.88(0.04) |20.87 |0.87(0.04) |20.79 |0.87(0.04) |20.79 |
## |5 |BMI.gmc |-0.10(0.03) |-3.60 |-0.10(0.03) |-3.61 |-0.10(0.03) |-3.55 |
## |6 |fs.w |-0.16(0.03) |-4.96 |-0.16(0.03) |-4.71 |-0.16(0.05) |-3.36 |
## |11 |f.nd | | |-0.02(0.02) |-1.01 |-0.02(0.02) |-1.01 |
## |12 |insomnia [1] | | | | |0.00(0.19) |0.01 |
## |13 |fs.w * insomnia [1] | | | | |0.01(0.07) |0.14 |
## |14 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |15 |Observations |3798 |3798 |3798 |NA |NA |NA |
## |7 |SD (Intercept) |0.86(NA) | |0.86(NA) | |0.86(NA) | |
## |8 |SD (fs.w) |0.21(NA) | |0.21(NA) | |0.21(NA) | |
## |10 |SD (Observations) |1.05(NA) | |1.05(NA) | |1.05(NA) | |
## |9 |Cor (Intercept~ID) |-0.57(NA) | |-0.57(NA) | |-0.57(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
Comments:
both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the both distributions) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term
SO.num, weekday.sleep, BMI, all raw and aggregate diary ratings, and next day stress are associated with a significant LRT, and stronger evidence in terms of Aw
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all raw and aggregate diary ratings (with the weakest effect estimated for mood), and next day stress and PsyDist; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect
s.variab variables are modeled by considering the subset of complete s.variab and dailyDiary data, whereas dailyAct data are ignored since none of the s.variab variables was substantially predicted by TotalSteps1000. Note that all models are specified with nAGQ = 0 due to convergence problems, implying quite conservative estimates with large standard errors.
s.variab <- paste(c(s.archit[1:3],s.timing),"SSD",sep=".")
In section 5.1, TIB.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher TIB.SSD during weekend), BMI (higher TIB.SSD for participants with higher BMI), and insomnia (lower TIB.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.
# adding constant to each value to avoid zeros
ema$TIB.SSDc <- ema$TIB.SSD + 0.001
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TIB.SSD by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results (considering M3 for stress and PsyDist, which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]%in%c("stress","PsyDist","fs.w"),2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",
fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
family="gamma",link="log",transform="exp",nAGQ=0,outputs=outputs,ran.eff=ran.eff, # nAGQ = 0 to reach convergence
coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing TIB.SSD by stress
## ###########################################
##
## Running GLMER analysis of TIB.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): TIB.SSDc ~ (1|ID)
## - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + (stress.mc|ID)
## - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## weekday.sleep BMI.gmc stress.mc s.nd.mc
## 1.023364 1.036153 2.270270 1.062629
## insomnia stress.mc:insomnia
## 1.298341 2.549969
##
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 70694.01| 70712.51| -35344.00| 70688.01| NA| NA| NA|
## |weekday.sleep | 4| 70659.66| 70684.33| -35325.83| 70651.66| 36.344| 1| 0.000|
## |BMI.gmc | 5| 70653.05| 70683.89| -35321.53| 70643.05| 8.608| 1| 0.003|
## |stress.mc | 8| 70650.62| 70699.96| -35317.31| 70634.62| 8.436| 3| 0.038|
## |s.nd.mc | 9| 70650.84| 70706.35| -35316.42| 70632.84| 1.775| 1| 0.183|
## |insomnia | 10| 70648.18| 70709.85| -35314.09| 70628.18| 4.665| 1| 0.031|
## |stress.mc:insomnia | 11| 70650.04| 70717.88| -35314.02| 70628.04| 0.137| 1| 0.712|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.965
## - stress.mc = 0.765
## - s.nd.mc = 0.406
## - insomnia = 0.606
## - stress.mc:insomnia = 0.193
## Selected model: insomnia
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2 |(Intercept) |9674.62(904.68) |98.14 |9693.72(907.17) |98.09 |10947.97(1415.36) |71.94 |
## |3 |weekday.sleep [weekend] |1.40(0.08) |5.81 |1.38(0.08) |5.61 |1.39(0.08) |5.63 |
## |4 |BMI.gmc |1.06(0.03) |2.18 |1.06(0.03) |2.18 |1.05(0.03) |1.92 |
## |5 |stress.mc |0.97(0.03) |-0.85 |0.98(0.03) |-0.58 |0.97(0.05) |-0.73 |
## |10 |s.nd.mc | | |0.96(0.03) |-1.34 |0.96(0.03) |-1.34 |
## |11 |insomnia [1] | | | | |0.79(0.14) |-1.32 |
## |12 |stress.mc * insomnia [1] | | | | |1.02(0.07) |0.32 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.29(NA) | |2.30(NA) | |2.24(NA) | |
## |7 |SD (stress.mc) |1.15(NA) | |1.15(NA) | |1.15(NA) | |
## |9 |SD (Observations) |3.42(NA) | |3.42(NA) | |3.41(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB.SSD by worry
## ###########################################
##
## Running GLMER analysis of TIB.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): TIB.SSDc ~ (1|ID)
## - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + (worry.mc|ID)
## - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 70694.01| 70712.51| -35344.00| 70688.01| NA| NA| NA|
## |weekday.sleep | 4| 70659.66| 70684.33| -35325.83| 70651.66| 36.344| 1| 0.000|
## |BMI.gmc | 5| 70653.05| 70683.89| -35321.53| 70643.05| 8.608| 1| 0.003|
## |worry.mc | 8| 70654.95| 70704.28| -35319.47| 70638.95| 4.110| 3| 0.250|
## |w.nd.mc | 9| 70655.79| 70711.29| -35318.89| 70637.79| 1.157| 1| 0.282|
## |insomnia | 10| 70654.87| 70716.54| -35317.43| 70634.87| 2.924| 1| 0.087|
## |worry.mc:insomnia | 11| 70655.75| 70723.59| -35316.88| 70633.75| 1.114| 1| 0.291|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.965
## - worry.mc = 0.273
## - w.nd.mc = 0.152
## - insomnia = 0.194
## - worry.mc:insomnia = 0.111
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2 |(Intercept) |9657.21(906.41) |97.76 |9648.17(906.89) |97.61 |10854.53(1413.27) |71.37 |
## |3 |weekday.sleep [weekend] |1.40(0.08) |5.82 |1.40(0.08) |5.83 |1.41(0.08) |5.88 |
## |4 |BMI.gmc |1.06(0.03) |2.04 |1.06(0.03) |2.03 |1.05(0.03) |1.84 |
## |5 |worry.mc |1.00(0.03) |0.04 |1.01(0.03) |0.26 |1.04(0.05) |0.84 |
## |10 |w.nd.mc | | |0.97(0.03) |-1.14 |0.97(0.03) |-1.13 |
## |11 |insomnia [1] | | | | |0.79(0.15) |-1.28 |
## |12 |worry.mc * insomnia [1] | | | | |0.94(0.06) |-0.93 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.30(NA) | |2.30(NA) | |2.25(NA) | |
## |7 |SD (worry.mc) |1.10(NA) | |1.10(NA) | |1.09(NA) | |
## |9 |SD (Observations) |3.43(NA) | |3.43(NA) | |3.42(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB.SSD by mood
## ###########################################
##
## Running GLMER analysis of TIB.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): TIB.SSDc ~ (1|ID)
## - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + (mood.mc|ID)
## - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 70694.01| 70712.51| -35344.00| 70688.01| NA| NA| NA|
## |weekday.sleep | 4| 70659.66| 70684.33| -35325.83| 70651.66| 36.344| 1| 0.000|
## |BMI.gmc | 5| 70653.05| 70683.89| -35321.53| 70643.05| 8.608| 1| 0.003|
## |mood.mc | 8| 70658.80| 70708.14| -35321.40| 70642.80| 0.255| 3| 0.968|
## |m.nd.mc | 9| 70657.30| 70712.81| -35319.65| 70639.30| 3.499| 1| 0.061|
## |insomnia | 10| 70655.30| 70716.98| -35317.65| 70635.30| 3.996| 1| 0.046|
## |mood.mc:insomnia | 11| 70656.99| 70724.83| -35317.49| 70634.99| 0.320| 1| 0.571|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.965
## - mood.mc = 0.052
## - m.nd.mc = 0.099
## - insomnia = 0.211
## - mood.mc:insomnia = 0.084
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2 |(Intercept) |9686.60(903.33) |98.42 |9678.53(898.96) |98.81 |10932.13(1408.83) |72.16 |
## |3 |weekday.sleep [weekend] |1.40(0.08) |5.77 |1.40(0.08) |5.75 |1.39(0.08) |5.72 |
## |4 |BMI.gmc |1.06(0.03) |2.01 |1.06(0.03) |2.03 |1.05(0.03) |1.82 |
## |5 |mood.mc |1.00(0.03) |0.14 |1.01(0.03) |0.34 |0.99(0.05) |-0.30 |
## |10 |m.nd.mc | | |0.95(0.03) |-1.78 |0.95(0.03) |-1.82 |
## |11 |insomnia [1] | | | | |0.79(0.14) |-1.32 |
## |12 |mood.mc * insomnia [1] | | | | |1.04(0.06) |0.59 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.29(NA) | |2.28(NA) | |2.23(NA) | |
## |7 |SD (mood.mc) |1.02(NA) | |1.02(NA) | |1.03(NA) | |
## |9 |SD (Observations) |3.43(NA) | |3.43(NA) | |3.43(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB.SSD by PsyDist
## ###########################################
##
## Running GLMER analysis of TIB.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): TIB.SSDc ~ (1|ID)
## - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 70694.01| 70712.51| -35344.00| 70688.01| NA| NA| NA|
## |weekday.sleep | 4| 70659.66| 70684.33| -35325.83| 70651.66| 36.344| 1| 0.000|
## |BMI.gmc | 5| 70653.05| 70683.89| -35321.53| 70643.05| 8.608| 1| 0.003|
## |PsyDist.mc | 8| 70653.64| 70702.98| -35318.82| 70637.64| 5.417| 3| 0.144|
## |P.nd.mc | 9| 70651.79| 70707.30| -35316.90| 70633.79| 3.846| 1| 0.050|
## |insomnia | 10| 70649.88| 70711.56| -35314.94| 70629.88| 3.907| 1| 0.048|
## |PsyDist.mc:insomnia | 11| 70651.88| 70719.73| -35314.94| 70629.88| 0.000| 1| 0.991|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.965
## - PsyDist.mc = 0.419
## - P.nd.mc = 0.513
## - insomnia = 0.571
## - PsyDist.mc:insomnia = 0.174
## Selected model: insomnia
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2 |(Intercept) |9651.15(904.76) |97.87 |9644.93(903.61) |97.92 |10880.06(1413.95) |71.52 |
## |3 |weekday.sleep [weekend] |1.40(0.08) |5.81 |1.40(0.08) |5.72 |1.39(0.08) |5.70 |
## |4 |BMI.gmc |1.06(0.03) |2.15 |1.06(0.03) |2.17 |1.05(0.03) |1.95 |
## |5 |PsyDist.mc |0.99(0.04) |-0.14 |1.02(0.04) |0.38 |1.01(0.06) |0.17 |
## |10 |P.nd.mc | | |0.93(0.04) |-1.97 |0.93(0.04) |-1.98 |
## |11 |insomnia [1] | | | | |0.79(0.14) |-1.30 |
## |12 |PsyDist.mc * insomnia [1] | | | | |1.00(0.08) |-0.00 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.30(NA) | |2.30(NA) | |2.25(NA) | |
## |7 |SD (PsyDist.mc) |1.16(NA) | |1.16(NA) | |1.16(NA) | |
## |9 |SD (Observations) |3.43(NA) | |3.42(NA) | |3.42(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TIB.SSD by fs.w
## ###########################################
##
## Running GLMER analysis of TIB.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
##
## Model specification:
## - model M0 (null): TIB.SSDc ~ (1|ID)
## - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + (fs.w|ID)
## - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (fs.w|ID)
## - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 70694.01| 70712.51| -35344.00| 70688.01| NA| NA| NA|
## |weekday.sleep | 4| 70659.66| 70684.33| -35325.83| 70651.66| 36.344| 1| 0.000|
## |BMI.gmc | 5| 70653.05| 70683.89| -35321.53| 70643.05| 8.608| 1| 0.003|
## |fs.w | 8| 70654.26| 70703.60| -35319.13| 70638.26| 4.791| 3| 0.188|
## |f.nd | 9| 70652.86| 70708.36| -35317.43| 70634.86| 3.406| 1| 0.065|
## |insomnia | 10| 70651.07| 70712.74| -35315.53| 70631.07| 3.791| 1| 0.052|
## |fs.w:insomnia | 11| 70653.03| 70720.87| -35315.51| 70631.03| 0.038| 1| 0.845|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.965
## - fs.w = 0.345
## - f.nd = 0.411
## - insomnia = 0.501
## - fs.w:insomnia = 0.158
## Selected model: insomnia
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2 |(Intercept) |9649.45(904.37) |97.89 |9643.08(904.58) |97.80 |10889.66(1417.07) |71.43 |
## |3 |weekday.sleep [weekend] |1.40(0.08) |5.81 |1.40(0.08) |5.76 |1.40(0.08) |5.74 |
## |4 |BMI.gmc |1.06(0.03) |2.12 |1.06(0.03) |2.13 |1.05(0.03) |1.91 |
## |5 |fs.w |1.00(0.03) |-0.03 |1.02(0.04) |0.44 |1.02(0.05) |0.33 |
## |10 |f.nd | | |0.94(0.03) |-1.89 |0.94(0.03) |-1.90 |
## |11 |insomnia [1] | | | | |0.79(0.14) |-1.31 |
## |12 |fs.w * insomnia [1] | | | | |0.99(0.07) |-0.14 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.30(NA) | |2.30(NA) | |2.25(NA) | |
## |7 |SD (fs.w) |1.13(NA) | |1.12(NA) | |1.12(NA) | |
## |9 |SD (Observations) |3.43(NA) | |3.43(NA) | |3.42(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress
weekday.sleep, BMI, insomnia, stress, and next day PsyDist are associated with a significant LRT, whereas weekday.sleep, BMI, insomnia, stress, PsyDist, and next day stress, PsyDist, and fs showed stronger evidence in terms of Aw
however, only the effects reported in section 5.1 are substantial, and insomnia is no longer substantially associated with TIB after the inclusion of any diary rating in the model (possibly due to nAGQ=0)
In section 5.1, TST.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher TST.SSD during weekend), BMI (higher TST.SSD for participants with higher BMI), and insomnia (lower TST.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.
# adding constant to each value to avoid zeros
ema$TST.SSDc <- ema$TST.SSD + 0.001
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TST.SSD by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results (considering M3 for mood and PsyDist, which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]%in%c("mood","PsyDist","fs.w"),2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",
fix.eff=predictors,ran.eff=ran.eff, # day i+1
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
family="gamma",link="log",transform="exp",nAGQ=0,outputs=outputs,ran.eff=ran.eff, # nAGQ = 0 to reach convergence
coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing TST.SSD by stress
## ###########################################
##
## Running GLMER analysis of TST.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): TST.SSDc ~ (1|ID)
## - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + (stress.mc|ID)
## - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## weekday.sleep BMI.gmc stress.mc s.nd.mc
## 1.023460 1.035878 2.274386 1.063301
## insomnia stress.mc:insomnia
## 1.282933 2.536066
##
##
## - Running likelihood ratio test:
## Selected model: stress.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 69254.16| 69272.66| -34624.08| 69248.16| NA| NA| NA|
## |weekday.sleep | 4| 69223.49| 69248.16| -34607.75| 69215.49| 32.668| 1| 0.000|
## |BMI.gmc | 5| 69218.09| 69248.93| -34604.04| 69208.09| 7.400| 1| 0.007|
## |stress.mc | 8| 69215.92| 69265.26| -34599.96| 69199.92| 8.171| 3| 0.043|
## |s.nd.mc | 9| 69216.41| 69271.91| -34599.20| 69198.41| 1.513| 1| 0.219|
## |insomnia | 10| 69215.10| 69276.77| -34597.55| 69195.10| 3.310| 1| 0.069|
## |stress.mc:insomnia | 11| 69217.09| 69284.93| -34597.55| 69195.09| 0.005| 1| 0.945|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.937
## - stress.mc = 0.735
## - s.nd.mc = 0.366
## - insomnia = 0.413
## - stress.mc:insomnia = 0.132
## Selected model: insomnia
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2 |(Intercept) |7822.28(713.11) |98.34 |7838.43(715.42) |98.24 |8727.29(1107.31) |71.52 |
## |3 |weekday.sleep [weekend] |1.37(0.08) |5.63 |1.36(0.08) |5.42 |1.36(0.08) |5.43 |
## |4 |BMI.gmc |1.05(0.03) |2.01 |1.05(0.03) |2.03 |1.05(0.03) |1.80 |
## |5 |stress.mc |0.98(0.03) |-0.76 |0.98(0.03) |-0.48 |0.98(0.05) |-0.44 |
## |10 |s.nd.mc | | |0.96(0.03) |-1.29 |0.96(0.03) |-1.28 |
## |11 |insomnia [1] | | | | |0.81(0.14) |-1.19 |
## |12 |stress.mc * insomnia [1] | | | | |1.00(0.06) |0.06 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.25(NA) | |2.25(NA) | |2.21(NA) | |
## |7 |SD (stress.mc) |1.14(NA) | |1.14(NA) | |1.14(NA) | |
## |9 |SD (Observations) |3.35(NA) | |3.35(NA) | |3.35(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST.SSD by worry
## ###########################################
##
## Running GLMER analysis of TST.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): TST.SSDc ~ (1|ID)
## - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + (worry.mc|ID)
## - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: BMI.gmc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 69254.16| 69272.66| -34624.08| 69248.16| NA| NA| NA|
## |weekday.sleep | 4| 69223.49| 69248.16| -34607.75| 69215.49| 32.668| 1| 0.000|
## |BMI.gmc | 5| 69218.09| 69248.93| -34604.04| 69208.09| 7.400| 1| 0.007|
## |worry.mc | 8| 69221.00| 69270.34| -34602.50| 69205.00| 3.089| 3| 0.378|
## |w.nd.mc | 9| 69221.30| 69276.80| -34601.65| 69203.30| 1.703| 1| 0.192|
## |insomnia | 10| 69221.14| 69282.81| -34600.57| 69201.14| 2.163| 1| 0.141|
## |worry.mc:insomnia | 11| 69221.89| 69289.73| -34599.94| 69199.89| 1.249| 1| 0.264|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.937
## - worry.mc = 0.179
## - w.nd.mc = 0.134
## - insomnia = 0.127
## - worry.mc:insomnia = 0.08
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2 |(Intercept) |7811.36(717.22) |97.62 |7804.42(717.26) |97.52 |8644.18(1105.88) |70.85 |
## |3 |weekday.sleep [weekend] |1.38(0.08) |5.66 |1.38(0.08) |5.67 |1.38(0.08) |5.72 |
## |4 |BMI.gmc |1.05(0.03) |1.90 |1.05(0.03) |1.89 |1.05(0.03) |1.72 |
## |5 |worry.mc |1.01(0.03) |0.45 |1.02(0.03) |0.69 |1.05(0.05) |1.21 |
## |10 |w.nd.mc | | |0.96(0.03) |-1.37 |0.96(0.03) |-1.36 |
## |11 |insomnia [1] | | | | |0.82(0.15) |-1.13 |
## |12 |worry.mc * insomnia [1] | | | | |0.94(0.05) |-1.03 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.26(NA) | |2.26(NA) | |2.22(NA) | |
## |7 |SD (worry.mc) |1.08(NA) | |1.08(NA) | |1.07(NA) | |
## |9 |SD (Observations) |3.37(NA) | |3.36(NA) | |3.36(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST.SSD by mood
## ###########################################
##
## Running GLMER analysis of TST.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): TST.SSDc ~ (1|ID)
## - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + (mood.mc|ID)
## - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: m.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 69254.16| 69272.66| -34624.08| 69248.16| NA| NA| NA|
## |weekday.sleep | 4| 69223.49| 69248.16| -34607.75| 69215.49| 32.668| 1| 0.000|
## |BMI.gmc | 5| 69218.09| 69248.93| -34604.04| 69208.09| 7.400| 1| 0.007|
## |mood.mc | 8| 69223.65| 69272.99| -34603.83| 69207.65| 0.437| 3| 0.932|
## |m.nd.mc | 9| 69220.28| 69275.79| -34601.14| 69202.28| 5.374| 1| 0.020|
## |insomnia | 10| 69219.35| 69281.02| -34599.67| 69199.35| 2.935| 1| 0.087|
## |mood.mc:insomnia | 11| 69221.31| 69289.15| -34599.65| 69199.31| 0.038| 1| 0.846|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.937
## - mood.mc = 0.055
## - m.nd.mc = 0.229
## - insomnia = 0.267
## - mood.mc:insomnia = 0.091
## Selected model: BMI.gmc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2 |(Intercept) |7834.19(716.33) |98.06 |7824.25(711.92) |98.53 |8702.17(1103.21) |71.55 |
## |3 |weekday.sleep [weekend] |1.37(0.08) |5.60 |1.37(0.08) |5.58 |1.37(0.08) |5.59 |
## |4 |BMI.gmc |1.05(0.03) |1.90 |1.05(0.03) |1.93 |1.05(0.03) |1.73 |
## |5 |mood.mc |1.02(0.03) |0.56 |1.02(0.03) |0.79 |1.03(0.05) |0.65 |
## |10 |m.nd.mc | | |0.94(0.03) |-2.29 |0.94(0.03) |-2.31 |
## |11 |insomnia [1] | | | | |0.81(0.14) |-1.18 |
## |12 |mood.mc * insomnia [1] | | | | |0.99(0.06) |-0.19 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.25(NA) | |2.24(NA) | |2.20(NA) | |
## |7 |SD (mood.mc) |1.01(NA) | |1.02(NA) | |1.01(NA) | |
## |9 |SD (Observations) |3.37(NA) | |3.37(NA) | |3.37(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST.SSD by PsyDist
## ###########################################
##
## Running GLMER analysis of TST.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): TST.SSDc ~ (1|ID)
## - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: P.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 69254.16| 69272.66| -34624.08| 69248.16| NA| NA| NA|
## |weekday.sleep | 4| 69223.49| 69248.16| -34607.75| 69215.49| 32.668| 1| 0.000|
## |BMI.gmc | 5| 69218.09| 69248.93| -34604.04| 69208.09| 7.400| 1| 0.007|
## |PsyDist.mc | 8| 69219.50| 69268.84| -34601.75| 69203.50| 4.587| 3| 0.205|
## |P.nd.mc | 9| 69216.32| 69271.83| -34599.16| 69198.32| 5.183| 1| 0.023|
## |insomnia | 10| 69215.72| 69277.39| -34597.86| 69195.72| 2.601| 1| 0.107|
## |PsyDist.mc:insomnia | 11| 69217.47| 69285.31| -34597.74| 69195.47| 0.248| 1| 0.618|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.937
## - PsyDist.mc = 0.316
## - P.nd.mc = 0.608
## - insomnia = 0.451
## - PsyDist.mc:insomnia = 0.158
## Selected model: insomnia
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2 |(Intercept) |7802.25(714.06) |97.93 |7798.21(712.90) |98.03 |8659.59(1103.51) |71.15 |
## |3 |weekday.sleep [weekend] |1.38(0.08) |5.66 |1.37(0.08) |5.54 |1.37(0.08) |5.54 |
## |4 |BMI.gmc |1.05(0.03) |1.96 |1.05(0.03) |2.01 |1.05(0.03) |1.82 |
## |5 |PsyDist.mc |1.01(0.04) |0.26 |1.03(0.04) |0.85 |1.05(0.06) |0.86 |
## |10 |P.nd.mc | | |0.92(0.03) |-2.33 |0.92(0.03) |-2.33 |
## |11 |insomnia [1] | | | | |0.81(0.15) |-1.15 |
## |12 |PsyDist.mc * insomnia [1] | | | | |0.97(0.08) |-0.44 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.25(NA) | |2.25(NA) | |2.22(NA) | |
## |7 |SD (PsyDist.mc) |1.14(NA) | |1.14(NA) | |1.13(NA) | |
## |9 |SD (Observations) |3.36(NA) | |3.36(NA) | |3.36(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing TST.SSD by fs.w
## ###########################################
##
## Running GLMER analysis of TST.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Grand-mean-centering BMI
##
## Model specification:
## - model M0 (null): TST.SSDc ~ (1|ID)
## - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
## - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
## - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + (fs.w|ID)
## - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (fs.w|ID)
## - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: f.nd
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 69254.16| 69272.66| -34624.08| 69248.16| NA| NA| NA|
## |weekday.sleep | 4| 69223.49| 69248.16| -34607.75| 69215.49| 32.668| 1| 0.000|
## |BMI.gmc | 5| 69218.09| 69248.93| -34604.04| 69208.09| 7.400| 1| 0.007|
## |fs.w | 8| 69220.12| 69269.46| -34602.06| 69204.12| 3.971| 3| 0.265|
## |f.nd | 9| 69217.37| 69272.87| -34599.68| 69199.37| 4.755| 1| 0.029|
## |insomnia | 10| 69216.80| 69278.47| -34598.40| 69196.80| 2.565| 1| 0.109|
## |fs.w:insomnia | 11| 69218.38| 69286.23| -34598.19| 69196.38| 0.415| 1| 0.520|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - BMI.gmc = 0.937
## - fs.w = 0.254
## - f.nd = 0.501
## - insomnia = 0.399
## - fs.w:insomnia = 0.153
## Selected model: insomnia
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2 |(Intercept) |7801.91(714.39) |97.88 |7797.91(714.36) |97.82 |8667.67(1106.54) |71.03 |
## |3 |weekday.sleep [weekend] |1.38(0.08) |5.67 |1.37(0.08) |5.59 |1.37(0.08) |5.60 |
## |4 |BMI.gmc |1.05(0.03) |1.94 |1.05(0.03) |1.97 |1.05(0.03) |1.78 |
## |5 |fs.w |1.01(0.03) |0.40 |1.03(0.03) |0.92 |1.05(0.05) |1.02 |
## |10 |f.nd | | |0.93(0.03) |-2.26 |0.93(0.03) |-2.27 |
## |11 |insomnia [1] | | | | |0.81(0.15) |-1.16 |
## |12 |fs.w * insomnia [1] | | | | |0.96(0.06) |-0.58 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.25(NA) | |2.26(NA) | |2.22(NA) | |
## |7 |SD (fs.w) |1.10(NA) | |1.11(NA) | |1.10(NA) | |
## |9 |SD (Observations) |3.37(NA) | |3.36(NA) | |3.36(NA) | |
## |8 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc
weekday.sleep, BMI, stress, and next day PsyDist, and fs are associated with a significant LRT, and showed stronger evidence in terms of Aw; significant LRT is also shown by next day mood
in addition to the effects reported in section 5.1, substantial negative effects are estimated for next day Mood, PsyDist, and fs; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect; in particular, insomnia is no longer substantially associated with TST after the inclusion of any diary rating in the model (possibly due to nAGQ=0)
In section 5.1, WASO.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by SO.num (lower WASO.SSD for later than usual SO) and weekday.sleep (higher WASO.SSD during weekend).
# adding constant to each value to avoid zeros
ema$WASO.SSDc <- ema$WASO.SSD + 0.001
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WASO.SSD by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",
fix.eff=predictors,ran.eff=ran.eff, # day i+1
modelType=c("GLMER"),mc.predictors=mc.predictors,
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
ran.eff=ran.eff,modelType=c("GLMER"),mc.predictors=mc.predictors,
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors, # GLMER with mean-centered pred.
family="gamma",link="log",transform="exp",nAGQ=0,outputs=outputs,ran.eff=ran.eff, # nAGQ = 0 to reach covergence
coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing WASO.SSD by stress
## ###########################################
##
## Running GLMER analysis of WASO.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , stress , s.nd
##
## Model specification:
## - model M0 (null): WASO.SSDc ~ (1|ID)
## - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
## - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + (stress.mc|ID)
## - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc weekday.sleep stress.mc s.nd.mc
## 1.038607 1.057452 2.353146 1.077688
## insomnia stress.mc:insomnia
## 1.001031 2.306094
##
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 50279.26| 50297.77| -25136.63| 50273.26| NA| NA| NA|
## |SO.num.mc | 4| 50270.12| 50294.79| -25131.06| 50262.12| 11.149| 1| 0.001|
## |weekday.sleep | 5| 50239.96| 50270.80| -25114.98| 50229.96| 32.152| 1| 0.000|
## |stress.mc | 8| 50244.54| 50293.88| -25114.27| 50228.54| 1.425| 3| 0.700|
## |s.nd.mc | 9| 50246.48| 50301.98| -25114.24| 50228.48| 0.063| 1| 0.802|
## |insomnia | 10| 50247.31| 50308.98| -25113.65| 50227.31| 1.170| 1| 0.279|
## |stress.mc:insomnia | 11| 50246.69| 50314.53| -25112.34| 50224.69| 2.620| 1| 0.106|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.01
## - SO.num.mc vs. null model = 0.99
## - weekday.sleep = 1
## - stress.mc = 0.092
## - s.nd.mc = 0.034
## - insomnia = 0.022
## - stress.mc:insomnia = 0.029
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2 |(Intercept) |552.59(48.95) |71.29 |552.80(48.97) |71.29 |583.02(71.65) |51.82 |
## |3 |SO.num.mc |0.93(0.03) |-2.58 |0.93(0.03) |-2.58 |0.93(0.03) |-2.65 |
## |4 |weekday.sleep [weekend] |1.39(0.10) |4.53 |1.38(0.10) |4.48 |1.38(0.10) |4.49 |
## |5 |stress.mc |0.97(0.03) |-0.95 |0.97(0.03) |-0.86 |0.92(0.05) |-1.68 |
## |10 |s.nd.mc | | |0.99(0.04) |-0.23 |0.99(0.04) |-0.22 |
## |11 |insomnia [1] | | | | |0.90(0.15) |-0.62 |
## |12 |stress.mc * insomnia [1] | | | | |1.10(0.08) |1.36 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.11(NA) | |2.11(NA) | |2.09(NA) | |
## |7 |SD (stress.mc) |1.01(NA) | |1.01(NA) | |1.01(NA) | |
## |9 |SD (Observations) |3.91(NA) | |3.91(NA) | |3.91(NA) | |
## |8 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO.SSD by worry
## ###########################################
##
## Running GLMER analysis of WASO.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , worry , w.nd
##
## Model specification:
## - model M0 (null): WASO.SSDc ~ (1|ID)
## - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
## - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID)
## - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 50279.26| 50297.77| -25136.63| 50273.26| NA| NA| NA|
## |SO.num.mc | 4| 50270.12| 50294.79| -25131.06| 50262.12| 11.149| 1| 0.001|
## |weekday.sleep | 5| 50239.96| 50270.80| -25114.98| 50229.96| 32.152| 1| 0.000|
## |worry.mc | 8| 50240.88| 50290.22| -25112.44| 50224.88| 5.083| 3| 0.166|
## |w.nd.mc | 9| 50241.52| 50297.03| -25111.76| 50223.52| 1.357| 1| 0.244|
## |insomnia | 10| 50241.98| 50303.66| -25110.99| 50221.98| 1.540| 1| 0.215|
## |worry.mc:insomnia | 11| 50243.98| 50311.82| -25110.99| 50221.98| 0.000| 1| 1.000|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.01
## - SO.num.mc vs. null model = 0.99
## - weekday.sleep = 1
## - worry.mc = 0.387
## - w.nd.mc = 0.219
## - insomnia = 0.148
## - worry.mc:insomnia = 0.052
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2 |(Intercept) |551.89(48.14) |72.38 |551.21(48.04) |72.42 |585.24(70.64) |52.79 |
## |3 |SO.num.mc |0.93(0.03) |-2.57 |0.93(0.03) |-2.57 |0.93(0.03) |-2.59 |
## |4 |weekday.sleep [weekend] |1.39(0.10) |4.55 |1.39(0.10) |4.59 |1.39(0.10) |4.60 |
## |5 |worry.mc |0.99(0.04) |-0.16 |0.99(0.04) |-0.36 |0.98(0.06) |-0.29 |
## |10 |w.nd.mc | | |1.03(0.04) |0.95 |1.04(0.04) |0.96 |
## |11 |insomnia [1] | | | | |0.89(0.15) |-0.70 |
## |12 |worry.mc * insomnia [1] | | | | |1.01(0.08) |0.12 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.09(NA) | |2.09(NA) | |2.06(NA) | |
## |7 |SD (worry.mc) |1.15(NA) | |1.15(NA) | |1.15(NA) | |
## |9 |SD (Observations) |3.89(NA) | |3.89(NA) | |3.88(NA) | |
## |8 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO.SSD by mood
## ###########################################
##
## Running GLMER analysis of WASO.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , mood , m.nd
##
## Model specification:
## - model M0 (null): WASO.SSDc ~ (1|ID)
## - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
## - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + (mood.mc|ID)
## - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 50279.26| 50297.77| -25136.63| 50273.26| NA| NA| NA|
## |SO.num.mc | 4| 50270.12| 50294.79| -25131.06| 50262.12| 11.149| 1| 0.001|
## |weekday.sleep | 5| 50239.96| 50270.80| -25114.98| 50229.96| 32.152| 1| 0.000|
## |mood.mc | 8| 50245.69| 50295.03| -25114.85| 50229.69| 0.275| 3| 0.965|
## |m.nd.mc | 9| 50245.50| 50301.00| -25113.75| 50227.50| 2.191| 1| 0.139|
## |insomnia | 10| 50246.37| 50308.04| -25113.18| 50226.37| 1.133| 1| 0.287|
## |mood.mc:insomnia | 11| 50245.58| 50313.42| -25111.79| 50223.58| 2.789| 1| 0.095|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.01
## - SO.num.mc vs. null model = 0.99
## - weekday.sleep = 1
## - mood.mc = 0.054
## - m.nd.mc = 0.056
## - insomnia = 0.035
## - mood.mc:insomnia = 0.049
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2 |(Intercept) |552.19(48.90) |71.30 |551.19(48.56) |71.65 |582.54(71.10) |52.17 |
## |3 |SO.num.mc |0.93(0.03) |-2.55 |0.93(0.03) |-2.55 |0.93(0.03) |-2.61 |
## |4 |weekday.sleep [weekend] |1.39(0.10) |4.59 |1.40(0.10) |4.69 |1.40(0.10) |4.64 |
## |5 |mood.mc |1.00(0.04) |0.04 |1.00(0.04) |-0.06 |0.94(0.05) |-1.15 |
## |10 |m.nd.mc | | |1.04(0.04) |1.14 |1.04(0.04) |1.10 |
## |11 |insomnia [1] | | | | |0.90(0.15) |-0.64 |
## |12 |mood.mc * insomnia [1] | | | | |1.10(0.08) |1.31 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.11(NA) | |2.10(NA) | |2.08(NA) | |
## |7 |SD (mood.mc) |1.03(NA) | |1.04(NA) | |1.02(NA) | |
## |9 |SD (Observations) |3.91(NA) | |3.91(NA) | |3.91(NA) | |
## |8 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO.SSD by PsyDist
## ###########################################
##
## Running GLMER analysis of WASO.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): WASO.SSDc ~ (1|ID)
## - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
## - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 50279.26| 50297.77| -25136.63| 50273.26| NA| NA| NA|
## |SO.num.mc | 4| 50270.12| 50294.79| -25131.06| 50262.12| 11.149| 1| 0.001|
## |weekday.sleep | 5| 50239.96| 50270.80| -25114.98| 50229.96| 32.152| 1| 0.000|
## |PsyDist.mc | 8| 50243.53| 50292.87| -25113.76| 50227.53| 2.438| 3| 0.487|
## |P.nd.mc | 9| 50244.41| 50299.92| -25113.21| 50226.41| 1.114| 1| 0.291|
## |insomnia | 10| 50245.53| 50307.20| -25112.76| 50225.53| 0.887| 1| 0.346|
## |PsyDist.mc:insomnia | 11| 50245.31| 50313.15| -25111.66| 50223.31| 2.213| 1| 0.137|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.01
## - SO.num.mc vs. null model = 0.99
## - weekday.sleep = 1
## - PsyDist.mc = 0.144
## - P.nd.mc = 0.085
## - insomnia = 0.046
## - PsyDist.mc:insomnia = 0.049
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2 |(Intercept) |552.50(48.66) |71.69 |551.81(48.53) |71.79 |583.31(71.29) |52.11 |
## |3 |SO.num.mc |0.93(0.03) |-2.55 |0.93(0.03) |-2.55 |0.93(0.03) |-2.61 |
## |4 |weekday.sleep [weekend] |1.38(0.10) |4.51 |1.39(0.10) |4.58 |1.39(0.10) |4.57 |
## |5 |PsyDist.mc |0.98(0.05) |-0.51 |0.97(0.05) |-0.72 |0.90(0.07) |-1.48 |
## |10 |P.nd.mc | | |1.04(0.05) |0.80 |1.04(0.05) |0.79 |
## |11 |insomnia [1] | | | | |0.90(0.15) |-0.64 |
## |12 |PsyDist.mc * insomnia [1] | | | | |1.12(0.10) |1.21 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.10(NA) | |2.10(NA) | |2.08(NA) | |
## |7 |SD (PsyDist.mc) |1.11(NA) | |1.10(NA) | |1.08(NA) | |
## |9 |SD (Observations) |3.90(NA) | |3.90(NA) | |3.90(NA) | |
## |8 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
##
##
##
## ###########################################
## Analyzing WASO.SSD by fs.w
## ###########################################
##
## Running GLMER analysis of WASO.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering SO.num
##
## Model specification:
## - model M0 (null): WASO.SSDc ~ (1|ID)
## - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
## - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
## - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + (fs.w|ID)
## - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: weekday.sleep
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 50279.26| 50297.77| -25136.63| 50273.26| NA| NA| NA|
## |SO.num.mc | 4| 50270.12| 50294.79| -25131.06| 50262.12| 11.149| 1| 0.001|
## |weekday.sleep | 5| 50239.96| 50270.80| -25114.98| 50229.96| 32.152| 1| 0.000|
## |fs.w | 8| 50243.17| 50292.51| -25113.58| 50227.17| 2.795| 3| 0.424|
## |f.nd | 9| 50243.76| 50299.27| -25112.88| 50225.76| 1.404| 1| 0.236|
## |insomnia | 10| 50244.89| 50306.56| -25112.44| 50224.89| 0.875| 1| 0.349|
## |fs.w:insomnia | 11| 50245.27| 50313.11| -25111.64| 50223.27| 1.616| 1| 0.204|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.01
## - SO.num.mc vs. null model = 0.99
## - weekday.sleep = 1
## - fs.w = 0.168
## - f.nd = 0.111
## - insomnia = 0.059
## - fs.w:insomnia = 0.047
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2 |(Intercept) |552.45(48.59) |71.79 |551.60(48.43) |71.90 |582.85(71.18) |52.15 |
## |3 |SO.num.mc |0.93(0.03) |-2.59 |0.93(0.03) |-2.56 |0.93(0.03) |-2.60 |
## |4 |weekday.sleep [weekend] |1.39(0.10) |4.53 |1.39(0.10) |4.60 |1.39(0.10) |4.59 |
## |5 |fs.w |0.98(0.04) |-0.41 |0.97(0.04) |-0.64 |0.92(0.06) |-1.27 |
## |10 |f.nd | | |1.04(0.04) |0.91 |1.04(0.04) |0.89 |
## |11 |insomnia [1] | | | | |0.90(0.15) |-0.64 |
## |12 |fs.w * insomnia [1] | | | | |1.09(0.09) |1.04 |
## |13 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |14 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |6 |SD (Intercept) |2.10(NA) | |2.10(NA) | |2.08(NA) | |
## |7 |SD (fs.w) |1.11(NA) | |1.10(NA) | |1.09(NA) | |
## |9 |SD (Observations) |3.90(NA) | |3.90(NA) | |3.90(NA) | |
## |8 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 6
Comments:
both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc
only SO.num and weekday.sleep are associated with a significant LRT, and showed stronger evidence in terms of Aw
coherently, only the effects reported in section 5.1 are substantial
In section 5.1, SO.num.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher SO.num.SSD during weekend), and insomnia (lower SO.num.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.
# adding constant to each value to avoid zeros
ema$SO.num.SSDc <- ema$SO.num.SSD + 0.001
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SO.num.SSD by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results
res[[i]] <- rbind(res[[i]],cbind(measure="SO.num.SSDc",
glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,ran.eff=ran.eff, # nAGQ = 0 to reach convergence
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0,
outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SO.num.SSDc",
glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,ran.eff=ran.eff, # day i+1
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SO.num.SSDc",
glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing SO.num.SSD by stress
## ###########################################
##
## Running GLMER analysis of SO.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): SO.num.SSDc ~ (1|ID)
## - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: SO.num.SSDc ~ weekday.sleep + stress.mc + (stress.mc|ID)
## - model M3: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M4: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M5: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## weekday.sleep stress.mc s.nd.mc insomnia
## 1.024938 2.337149 1.073800 1.042699
## stress.mc:insomnia
## 2.344765
##
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 8829.535| 8848.037| -4411.767| 8823.535| NA| NA| NA|
## |weekday.sleep | 4| 8805.134| 8829.804| -4398.567| 8797.134| 26.401| 1| 0.000|
## |stress.mc | 7| 8810.160| 8853.331| -4398.080| 8796.160| 0.974| 3| 0.807|
## |s.nd.mc | 8| 8811.956| 8861.295| -4397.978| 8795.956| 0.204| 1| 0.651|
## |insomnia | 9| 8807.721| 8863.227| -4394.861| 8789.721| 6.235| 1| 0.013|
## |stress.mc:insomnia | 10| 8806.242| 8867.915| -4393.121| 8786.242| 3.480| 1| 0.062|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - stress.mc = 0.075
## - s.nd.mc = 0.03
## - insomnia = 0.198
## - stress.mc:insomnia = 0.293
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.52(0.20) |3.15 |1.52(0.20) |3.16 |1.81(0.33) |3.29 |
## |3 |weekday.sleep [weekend] |1.33(0.09) |4.42 |1.33(0.09) |4.34 |1.33(0.09) |4.36 |
## |4 |stress.mc |0.98(0.03) |-0.65 |0.98(0.03) |-0.54 |0.92(0.05) |-1.65 |
## |9 |s.nd.mc | | |0.99(0.03) |-0.39 |0.99(0.03) |-0.38 |
## |10 |insomnia [1] | | | | |0.71(0.18) |-1.37 |
## |11 |stress.mc * insomnia [1] | | | | |1.11(0.07) |1.61 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |3.37(NA) | |3.37(NA) | |3.22(NA) | |
## |6 |SD (stress.mc) |1.05(NA) | |1.05(NA) | |1.06(NA) | |
## |8 |SD (Observations) |3.68(NA) | |3.68(NA) | |3.67(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SO.num.SSD by worry
## ###########################################
##
## Running GLMER analysis of SO.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): SO.num.SSDc ~ (1|ID)
## - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: SO.num.SSDc ~ weekday.sleep + worry.mc + (worry.mc|ID)
## - model M3: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M4: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M5: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 8829.535| 8848.037| -4411.767| 8823.535| NA| NA| NA|
## |weekday.sleep | 4| 8805.134| 8829.804| -4398.567| 8797.134| 26.401| 1| 0.000|
## |worry.mc | 7| 8808.730| 8851.901| -4397.365| 8794.730| 2.404| 3| 0.493|
## |w.nd.mc | 8| 8809.695| 8859.034| -4396.848| 8793.695| 1.035| 1| 0.309|
## |insomnia | 9| 8807.004| 8862.510| -4394.502| 8789.004| 4.691| 1| 0.030|
## |worry.mc:insomnia | 10| 8808.231| 8869.905| -4394.116| 8788.231| 0.773| 1| 0.379|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - worry.mc = 0.142
## - w.nd.mc = 0.081
## - insomnia = 0.236
## - worry.mc:insomnia = 0.113
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.52(0.20) |3.16 |1.52(0.20) |3.16 |1.82(0.33) |3.29 |
## |3 |weekday.sleep [weekend] |1.32(0.09) |4.31 |1.32(0.09) |4.29 |1.32(0.09) |4.27 |
## |4 |worry.mc |0.99(0.03) |-0.21 |1.00(0.03) |-0.06 |0.97(0.05) |-0.63 |
## |9 |w.nd.mc | | |0.97(0.03) |-0.86 |0.97(0.03) |-0.90 |
## |10 |insomnia [1] | | | | |0.70(0.18) |-1.38 |
## |11 |worry.mc * insomnia [1] | | | | |1.06(0.07) |0.81 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |3.36(NA) | |3.36(NA) | |3.23(NA) | |
## |6 |SD (worry.mc) |1.08(NA) | |1.09(NA) | |1.08(NA) | |
## |8 |SD (Observations) |3.68(NA) | |3.68(NA) | |3.68(NA) | |
## |7 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SO.num.SSD by mood
## ###########################################
##
## Running GLMER analysis of SO.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): SO.num.SSDc ~ (1|ID)
## - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: SO.num.SSDc ~ weekday.sleep + mood.mc + (mood.mc|ID)
## - model M3: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M4: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M5: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 8829.535| 8848.037| -4411.767| 8823.535| NA| NA| NA|
## |weekday.sleep | 4| 8805.134| 8829.804| -4398.567| 8797.134| 26.401| 1| 0.000|
## |mood.mc | 7| 8808.840| 8852.012| -4397.420| 8794.840| 2.294| 3| 0.514|
## |m.nd.mc | 8| 8808.803| 8858.142| -4396.402| 8792.803| 2.037| 1| 0.153|
## |insomnia | 9| 8805.901| 8861.407| -4393.951| 8787.901| 4.902| 1| 0.027|
## |mood.mc:insomnia | 10| 8807.499| 8869.172| -4393.749| 8787.499| 0.402| 1| 0.526|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - mood.mc = 0.136
## - m.nd.mc = 0.121
## - insomnia = 0.341
## - mood.mc:insomnia = 0.133
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.52(0.20) |3.17 |1.52(0.20) |3.18 |1.82(0.33) |3.29 |
## |3 |weekday.sleep [weekend] |1.32(0.09) |4.28 |1.32(0.09) |4.25 |1.32(0.09) |4.25 |
## |4 |mood.mc |0.96(0.03) |-1.17 |0.97(0.03) |-1.04 |0.94(0.05) |-1.10 |
## |9 |m.nd.mc | | |0.96(0.03) |-1.27 |0.96(0.03) |-1.27 |
## |10 |insomnia [1] | | | | |0.71(0.18) |-1.36 |
## |11 |mood.mc * insomnia [1] | | | | |1.04(0.07) |0.56 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |3.36(NA) | |3.35(NA) | |3.22(NA) | |
## |6 |SD (mood.mc) |1.03(NA) | |1.04(NA) | |1.03(NA) | |
## |8 |SD (Observations) |3.68(NA) | |3.68(NA) | |3.68(NA) | |
## |7 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SO.num.SSD by PsyDist
## ###########################################
##
## Running GLMER analysis of SO.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): SO.num.SSDc ~ (1|ID)
## - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M3: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M4: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M5: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 8829.535| 8848.037| -4411.767| 8823.535| NA| NA| NA|
## |weekday.sleep | 4| 8805.134| 8829.804| -4398.567| 8797.134| 26.401| 1| 0.000|
## |PsyDist.mc | 7| 8809.910| 8853.082| -4397.955| 8795.910| 1.224| 3| 0.747|
## |P.nd.mc | 8| 8810.548| 8859.887| -4397.274| 8794.548| 1.363| 1| 0.243|
## |insomnia | 9| 8807.862| 8863.368| -4394.931| 8789.862| 4.686| 1| 0.030|
## |PsyDist.mc:insomnia | 10| 8807.484| 8869.158| -4393.742| 8787.484| 2.377| 1| 0.123|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - PsyDist.mc = 0.084
## - P.nd.mc = 0.058
## - insomnia = 0.181
## - PsyDist.mc:insomnia = 0.179
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.52(0.20) |3.16 |1.53(0.20) |3.17 |1.82(0.33) |3.29 |
## |3 |weekday.sleep [weekend] |1.32(0.09) |4.30 |1.32(0.09) |4.23 |1.31(0.09) |4.19 |
## |4 |PsyDist.mc |0.97(0.04) |-0.81 |0.98(0.04) |-0.49 |0.91(0.06) |-1.41 |
## |9 |P.nd.mc | | |0.96(0.04) |-1.02 |0.96(0.04) |-1.03 |
## |10 |insomnia [1] | | | | |0.71(0.18) |-1.36 |
## |11 |PsyDist.mc * insomnia [1] | | | | |1.12(0.09) |1.40 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |3.37(NA) | |3.37(NA) | |3.23(NA) | |
## |6 |SD (PsyDist.mc) |1.04(NA) | |1.05(NA) | |1.02(NA) | |
## |8 |SD (Observations) |3.68(NA) | |3.68(NA) | |3.67(NA) | |
## |7 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing SO.num.SSD by fs.w
## ###########################################
##
## Running GLMER analysis of SO.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
##
## Model specification:
## - model M0 (null): SO.num.SSDc ~ (1|ID)
## - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: SO.num.SSDc ~ weekday.sleep + fs.w + (fs.w|ID)
## - model M3: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M4: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M5: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 8829.535| 8848.037| -4411.767| 8823.535| NA| NA| NA|
## |weekday.sleep | 4| 8805.134| 8829.804| -4398.567| 8797.134| 26.401| 1| 0.000|
## |fs.w | 7| 8809.548| 8852.719| -4397.774| 8795.548| 1.587| 3| 0.662|
## |f.nd | 8| 8810.232| 8859.571| -4397.116| 8794.232| 1.315| 1| 0.251|
## |insomnia | 9| 8807.653| 8863.159| -4394.826| 8789.653| 4.580| 1| 0.032|
## |fs.w:insomnia | 10| 8807.728| 8869.401| -4393.864| 8787.728| 1.925| 1| 0.165|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - fs.w = 0.099
## - f.nd = 0.066
## - insomnia = 0.193
## - fs.w:insomnia = 0.157
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.52(0.20) |3.16 |1.53(0.20) |3.17 |1.82(0.33) |3.30 |
## |3 |weekday.sleep [weekend] |1.32(0.09) |4.28 |1.32(0.09) |4.23 |1.31(0.09) |4.19 |
## |4 |fs.w |0.97(0.03) |-0.77 |0.98(0.04) |-0.48 |0.93(0.05) |-1.29 |
## |9 |f.nd | | |0.96(0.04) |-1.02 |0.96(0.04) |-1.05 |
## |10 |insomnia [1] | | | | |0.70(0.18) |-1.37 |
## |11 |fs.w * insomnia [1] | | | | |1.09(0.08) |1.26 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |3.37(NA) | |3.37(NA) | |3.24(NA) | |
## |6 |SD (fs.w) |1.05(NA) | |1.06(NA) | |1.04(NA) | |
## |8 |SD (Observations) |3.68(NA) | |3.68(NA) | |3.68(NA) | |
## |7 |Cor (Intercept~ID) |0.37(NA) | |0.37(NA) | |0.37(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) deviance residuals and (2) random effects are quite normally distributed (despite some marked deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc
only weekday.sleep and insomnia are associated with a significant LRT, whereas only weekday.sleep showed stronger evidence in terms of Aw
coherently, only weekday.sleep shows a substantial effect; in particular,insomnia is no longer substantially associated with SO.num.SSD after the inclusion of any diary rating in the model (possibly due to nAGQ=0)
In section 5.1, WakeUp.num.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher WakeUp.num.SSD during weekend).
# adding constant to each value to avoid zeros
ema$WakeUp.num.SSDc <- ema$WakeUp.num.SSD + 0.001
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WakeUp.num.SSD by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
# saving key results (considering M3, which showed sig. LRT and/or higher AW compared to M2)
res[[i]] <- rbind(res[[i]],cbind(measure="WakeUp.num.SSDc",
glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,ran.eff=ran.eff,nAGQ=0, # nAGQ = 0 to reach convergence
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
outputs="key.results",key.predictor=keys[1],key.model=keys[2],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WakeUp.num.SSDc",
glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WakeUp.num.SSDc",
glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,
modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",nAGQ=0, # nAGQ = 0
outputs=outputs,ran.eff=ran.eff, coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing WakeUp.num.SSD by stress
## ###########################################
##
## Running GLMER analysis of WakeUp.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering stress , s.nd
##
## Model specification:
## - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
## - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + (stress.mc|ID)
## - model M3: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M4: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M5: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## weekday.sleep stress.mc s.nd.mc insomnia
## 1.023670 2.282316 1.064686 1.214887
## stress.mc:insomnia
## 2.504184
##
##
## - Running likelihood ratio test:
## Selected model: s.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 10085.17| 10103.68| -5039.587| 10079.17| NA| NA| NA|
## |weekday.sleep | 4| 10047.11| 10071.78| -5019.557| 10039.11| 40.060| 1| 0.000|
## |stress.mc | 7| 10042.72| 10085.89| -5014.359| 10028.72| 10.397| 3| 0.015|
## |s.nd.mc | 8| 10040.59| 10089.93| -5012.295| 10024.59| 4.127| 1| 0.042|
## |insomnia | 9| 10041.40| 10096.91| -5011.701| 10023.40| 1.187| 1| 0.276|
## |stress.mc:insomnia | 10| 10043.41| 10105.08| -5011.703| 10023.41| 0.000| 1| 1.000|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - stress.mc = 0.9
## - s.nd.mc = 0.723
## - insomnia = 0.325
## - stress.mc:insomnia = 0.107
## Selected model: s.nd.mc
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.90(0.20) |6.14 |1.91(0.20) |6.17 |2.04(0.30) |4.88 |
## |3 |weekday.sleep [weekend] |1.43(0.09) |5.97 |1.41(0.09) |5.64 |1.41(0.09) |5.63 |
## |4 |stress.mc |0.94(0.03) |-2.01 |0.95(0.03) |-1.54 |0.95(0.05) |-1.03 |
## |9 |s.nd.mc | | |0.94(0.03) |-1.98 |0.94(0.03) |-1.98 |
## |10 |insomnia [1] | | | | |0.87(0.18) |-0.66 |
## |11 |stress.mc * insomnia [1] | | | | |1.00(0.07) |-0.06 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |2.56(NA) | |2.56(NA) | |2.54(NA) | |
## |6 |SD (stress.mc) |1.15(NA) | |1.14(NA) | |1.14(NA) | |
## |8 |SD (Observations) |3.51(NA) | |3.51(NA) | |3.51(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing WakeUp.num.SSD by worry
## ###########################################
##
## Running GLMER analysis of WakeUp.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering worry , w.nd
##
## Model specification:
## - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
## - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + (worry.mc|ID)
## - model M3: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + (worry.mc|ID)
## - model M4: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + (worry.mc|ID)
## - model M5: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (worry.mc|ID)
##
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: w.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 10085.17| 10103.68| -5039.587| 10079.17| NA| NA| NA|
## |weekday.sleep | 4| 10047.11| 10071.78| -5019.557| 10039.11| 40.060| 1| 0.000|
## |worry.mc | 7| 10052.33| 10095.50| -5019.167| 10038.33| 0.780| 3| 0.854|
## |w.nd.mc | 8| 10048.75| 10098.08| -5016.373| 10032.75| 5.589| 1| 0.018|
## |insomnia | 9| 10049.69| 10105.19| -5015.844| 10031.69| 1.056| 1| 0.304|
## |worry.mc:insomnia | 10| 10051.35| 10113.03| -5015.677| 10031.35| 0.334| 1| 0.563|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - worry.mc = 0.069
## - w.nd.mc = 0.292
## - insomnia = 0.154
## - worry.mc:insomnia = 0.063
## Selected model: weekday.sleep
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.91(0.20) |6.15 |1.90(0.20) |6.13 |2.04(0.30) |4.87 |
## |3 |weekday.sleep [weekend] |1.44(0.09) |5.97 |1.44(0.09) |5.99 |1.44(0.09) |5.99 |
## |4 |worry.mc |0.98(0.03) |-0.55 |1.00(0.03) |-0.10 |1.02(0.05) |0.36 |
## |9 |w.nd.mc | | |0.93(0.03) |-2.39 |0.93(0.03) |-2.38 |
## |10 |insomnia [1] | | | | |0.87(0.18) |-0.69 |
## |11 |worry.mc * insomnia [1] | | | | |0.96(0.06) |-0.61 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |2.56(NA) | |2.56(NA) | |2.54(NA) | |
## |6 |SD (worry.mc) |1.04(NA) | |1.04(NA) | |1.04(NA) | |
## |8 |SD (Observations) |3.53(NA) | |3.51(NA) | |3.51(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing WakeUp.num.SSD by mood
## ###########################################
##
## Running GLMER analysis of WakeUp.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering mood , m.nd
##
## Model specification:
## - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
## - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + (mood.mc|ID)
## - model M3: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M4: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M5: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: m.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 10085.17| 10103.68| -5039.587| 10079.17| NA| NA| NA|
## |weekday.sleep | 4| 10047.11| 10071.78| -5019.557| 10039.11| 40.060| 1| 0.000|
## |mood.mc | 7| 10051.17| 10094.34| -5018.584| 10037.17| 1.946| 3| 0.584|
## |m.nd.mc | 8| 10045.83| 10095.17| -5014.917| 10029.83| 7.335| 1| 0.007|
## |insomnia | 9| 10046.46| 10101.96| -5014.228| 10028.46| 1.376| 1| 0.241|
## |mood.mc:insomnia | 10| 10048.03| 10109.71| -5014.018| 10028.03| 0.422| 1| 0.516|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - mood.mc = 0.116
## - m.nd.mc = 0.626
## - insomnia = 0.314
## - mood.mc:insomnia = 0.125
## Selected model: m.nd.mc
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.91(0.20) |6.14 |1.90(0.20) |6.13 |2.05(0.30) |4.89 |
## |3 |weekday.sleep [weekend] |1.44(0.09) |5.97 |1.43(0.09) |5.94 |1.43(0.09) |5.90 |
## |4 |mood.mc |0.97(0.03) |-0.85 |0.98(0.03) |-0.63 |0.96(0.05) |-0.84 |
## |9 |m.nd.mc | | |0.92(0.03) |-2.63 |0.92(0.03) |-2.65 |
## |10 |insomnia [1] | | | | |0.87(0.18) |-0.69 |
## |11 |mood.mc * insomnia [1] | | | | |1.03(0.07) |0.51 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |2.56(NA) | |2.56(NA) | |2.54(NA) | |
## |6 |SD (mood.mc) |1.06(NA) | |1.06(NA) | |1.07(NA) | |
## |8 |SD (Observations) |3.53(NA) | |3.52(NA) | |3.52(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing WakeUp.num.SSD by PsyDist
## ###########################################
##
## Running GLMER analysis of WakeUp.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
## - Mean-centering PsyDist , P.nd
##
## Model specification:
## - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
## - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + (PsyDist.mc|ID)
## - model M3: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M4: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M5: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: P.nd.mc
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 10085.17| 10103.68| -5039.587| 10079.17| NA| NA| NA|
## |weekday.sleep | 4| 10047.11| 10071.78| -5019.557| 10039.11| 40.060| 1| 0.000|
## |PsyDist.mc | 7| 10047.87| 10091.04| -5016.934| 10033.87| 5.245| 3| 0.155|
## |P.nd.mc | 8| 10040.32| 10089.66| -5012.160| 10024.32| 9.549| 1| 0.002|
## |insomnia | 9| 10041.00| 10096.51| -5011.500| 10023.00| 1.320| 1| 0.251|
## |PsyDist.mc:insomnia | 10| 10042.98| 10104.65| -5011.489| 10022.98| 0.022| 1| 0.882|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - PsyDist.mc = 0.407
## - P.nd.mc = 0.947
## - insomnia = 0.403
## - PsyDist.mc:insomnia = 0.13
## Selected model: P.nd.mc
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.91(0.20) |6.16 |1.91(0.20) |6.16 |2.05(0.30) |4.90 |
## |3 |weekday.sleep [weekend] |1.43(0.09) |5.89 |1.42(0.09) |5.73 |1.41(0.09) |5.71 |
## |4 |PsyDist.mc |0.94(0.04) |-1.46 |0.97(0.04) |-0.61 |0.97(0.06) |-0.47 |
## |9 |P.nd.mc | | |0.88(0.04) |-3.08 |0.88(0.04) |-3.09 |
## |10 |insomnia [1] | | | | |0.87(0.18) |-0.70 |
## |11 |PsyDist.mc * insomnia [1] | | | | |1.00(0.08) |0.05 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |2.56(NA) | |2.56(NA) | |2.53(NA) | |
## |6 |SD (PsyDist.mc) |1.13(NA) | |1.13(NA) | |1.13(NA) | |
## |8 |SD (Observations) |3.52(NA) | |3.51(NA) | |3.51(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
##
##
##
## ###########################################
## Analyzing WakeUp.num.SSD by fs.w
## ###########################################
##
## Running GLMER analysis of WakeUp.num.SSDc ...
##
## Preparing data...
## - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
## and 1 participants with no complete variables
##
## Model specification:
## - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
## - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
## - model M2: WakeUp.num.SSDc ~ weekday.sleep + fs.w + (fs.w|ID)
## - model M3: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + (fs.w|ID)
## - model M4: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M5: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants
## using the gamma family with the log link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: f.nd
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 10085.17| 10103.68| -5039.587| 10079.17| NA| NA| NA|
## |weekday.sleep | 4| 10047.11| 10071.78| -5019.557| 10039.11| 40.060| 1| 0.000|
## |fs.w | 7| 10049.11| 10092.28| -5017.556| 10035.11| 4.003| 3| 0.261|
## |f.nd | 8| 10041.62| 10090.96| -5012.810| 10025.62| 9.492| 1| 0.002|
## |insomnia | 9| 10042.28| 10097.79| -5012.140| 10024.28| 1.340| 1| 0.247|
## |fs.w:insomnia | 10| 10044.28| 10105.96| -5012.142| 10024.28| 0.000| 1| 1.000|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. weekday.sleep : = 0
## - weekday.sleep vs. null model = 1
## - fs.w = 0.269
## - f.nd = 0.919
## - insomnia = 0.398
## - fs.w:insomnia = 0.127
## Selected model: f.nd
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2 |(Intercept) |1.91(0.20) |6.16 |1.90(0.20) |6.14 |2.05(0.30) |4.91 |
## |3 |weekday.sleep [weekend] |1.43(0.09) |5.90 |1.42(0.09) |5.80 |1.42(0.09) |5.78 |
## |4 |fs.w |0.96(0.03) |-1.28 |0.98(0.03) |-0.49 |0.98(0.05) |-0.32 |
## |9 |f.nd | | |0.90(0.03) |-3.10 |0.90(0.03) |-3.11 |
## |10 |insomnia [1] | | | | |0.86(0.18) |-0.73 |
## |11 |fs.w * insomnia [1] | | | | |1.00(0.07) |-0.03 |
## |12 |N |92 ID |92 ID |92 ID |NA |NA |NA |
## |13 |Observations |3524 |3524 |3524 |NA |NA |NA |
## |5 |SD (Intercept) |2.56(NA) | |2.56(NA) | |2.54(NA) | |
## |6 |SD (fs.w) |1.10(NA) | |1.09(NA) | |1.10(NA) | |
## |8 |SD (Observations) |3.52(NA) | |3.51(NA) | |3.51(NA) | |
## |7 |Cor (Intercept~ID) |2.72(NA) | |2.72(NA) | |2.72(NA) | |
##
##
## - Plotting effect(s) estimated by model 5
Comments:
both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc
weekday.sleep and all next day raw and aggregate diary ratings are associated with a significant LRT, whereas weekday.sleep, stress, PsyDist, and next day stress, mood, PsyDist, and fs showed stronger evidence in terms of Aw
in addition to the effects reported in section 5.1, substantial negative effects are estimated for all next day raw and aggregate diary ratings (with the weakest effect estimated for stress), whereas neither insomnia nor its interaction with diary ratings showed a substantial effect
s.auton variables are modeled by considering the subset of complete s.auton, dailyDiary, and dailyAct data.
s.auton <- c("HR_NREM","HR_REM")
In section 5.1, HR_NREM was modeled by assuming a normal distribution for residuals, and it was substantially predicted by TotalSleep1000 (higher HR_NREM for higher than usual TotalSleep1000), weekday.sleep (higher HR_NREM during weekends), BMI (higher stageHR_TST for participants with higher BMI), sex (higher stageHR_TST in girls compared to boys), and the interaction between insomnia and sex (lower stageHR_TST in female insomnia compared to control insomnia). Contrarily to the other analyses, here sex is included (since it is an important predictor), while insomnia is added after diary ratings for better consistency. Note that the random slope for worry and fs is not included due to convergence problems.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing HR_NREM by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("TotalSteps1000","weekday.sleep","BMI","sex",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","fs.w")){ ran.eff <- "(1|ID)" } # removing random slope for fs to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "TotalSteps1000" # selecting mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("TotalSteps1000",diaryVars[i],nd) }
# saving key results (considering M3 for mood, which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]=="mood",2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",
fix.eff=predictors,ran.eff=ran.eff,gmc.predictors="BMI",
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",
fix.eff=predictors,ran.eff=ran.eff,gmc.predictors="BMI",
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing HR_NREM by stress
## ###########################################
##
## Running GLMER analysis of HR_NREM ...
##
## Preparing data...
## - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering TotalSteps1000 , stress , s.nd
##
## Model specification:
## - model M0 (null): HR_NREM ~ (1|ID)
## - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
## - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
## - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
## - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + (stress.mc|ID)
## - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## TotalSteps1000.mc weekday.sleep BMI.gmc sex
## 1.014818 1.031282 1.038552 1.006020
## stress.mc s.nd.mc insomnia stress.mc:insomnia
## 2.091369 1.060272 1.058735 2.086476
##
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 15802.17| 15819.95| -7898.084| 15796.17| NA| NA| NA|
## |TotalSteps1000.mc | 4| 15743.78| 15767.50| -7867.892| 15735.78| 60.384| 1| 0.000|
## |weekday.sleep | 5| 15741.49| 15771.13| -7865.746| 15731.49| 4.293| 1| 0.038|
## |BMI.gmc | 6| 15736.16| 15771.73| -7862.082| 15724.16| 7.328| 1| 0.007|
## |sex | 7| 15729.16| 15770.65| -7857.577| 15715.16| 9.009| 1| 0.003|
## |stress.mc | 10| 15724.61| 15783.89| -7852.306| 15704.61| 10.544| 3| 0.014|
## |s.nd.mc | 11| 15726.36| 15791.57| -7852.182| 15704.36| 0.248| 1| 0.619|
## |insomnia | 12| 15721.90| 15793.03| -7848.950| 15697.90| 6.464| 1| 0.011|
## |stress.mc:insomnia | 13| 15720.07| 15797.13| -7847.034| 15694.07| 3.831| 1| 0.050|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. TotalSteps1000.mc : = 0
## - TotalSteps1000.mc vs. null model = 1
## - weekday.sleep = 0.759
## - BMI.gmc = 0.916
## - sex = 0.968
## - stress.mc = 0.904
## - s.nd.mc = 0.273
## - insomnia = 0.718
## - stress.mc:insomnia = 0.642
## Selected model: stress.mc:insomnia
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |61.52(0.81) |75.95 |61.52(0.81) |75.96 |63.14(1.04) |60.81 |
## |3 |TotalSteps1000.mc |0.15(0.02) |7.72 |0.15(0.02) |7.68 |0.16(0.02) |7.80 |
## |4 |weekday.sleep [weekend] |0.39(0.17) |2.29 |0.37(0.17) |2.20 |0.38(0.17) |2.21 |
## |5 |BMI.gmc |0.55(0.20) |2.73 |0.55(0.20) |2.73 |0.45(0.20) |2.30 |
## |6 |sex [M] |-4.22(1.38) |-3.06 |-4.22(1.38) |-3.06 |-4.36(1.33) |-3.28 |
## |7 |stress.mc |0.17(0.10) |1.74 |0.18(0.10) |1.80 |-0.01(0.14) |-0.07 |
## |12 |s.nd.mc | | |-0.04(0.08) |-0.50 |-0.05(0.08) |-0.54 |
## |13 |insomnia [1] | | | | |-3.08(1.29) |-2.38 |
## |14 |stress.mc * insomnia [1] | | | | |0.38(0.19) |1.99 |
## |15 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |16 |Observations |2773 |2773 |2773 |NA |NA |NA |
## |8 |SD (Intercept) |6.15(NA) | |6.15(NA) | |5.96(NA) | |
## |9 |SD (stress.mc) |0.46(NA) | |0.46(NA) | |0.42(NA) | |
## |11 |SD (Observations) |1.95(NA) | |1.95(NA) | |1.95(NA) | |
## |10 |Cor (Intercept~ID) |0.14(NA) | |0.14(NA) | |0.32(NA) | |
##
##
## - Plotting effect(s) estimated by model 8
##
##
##
## ###########################################
## Analyzing HR_NREM by worry
## ###########################################
##
## Running GLMER analysis of HR_NREM ...
##
## Preparing data...
## - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering TotalSteps1000 , worry , w.nd
##
## Model specification:
## - model M0 (null): HR_NREM ~ (1|ID)
## - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
## - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
## - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
## - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + (1|ID)
## - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + (1|ID)
## - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + insomnia + (1|ID)
## - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
##
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 15802.17| 15819.95| -7898.084| 15796.17| NA| NA| NA|
## |TotalSteps1000.mc | 4| 15743.78| 15767.50| -7867.892| 15735.78| 60.384| 1| 0.000|
## |weekday.sleep | 5| 15741.49| 15771.13| -7865.746| 15731.49| 4.293| 1| 0.038|
## |BMI.gmc | 6| 15736.16| 15771.73| -7862.082| 15724.16| 7.328| 1| 0.007|
## |sex | 7| 15729.16| 15770.65| -7857.577| 15715.16| 9.009| 1| 0.003|
## |worry.mc | 8| 15731.15| 15778.57| -7857.574| 15715.15| 0.006| 1| 0.937|
## |w.nd.mc | 9| 15732.95| 15786.30| -7857.476| 15714.95| 0.196| 1| 0.658|
## |insomnia | 10| 15729.50| 15788.78| -7854.753| 15709.50| 5.447| 1| 0.020|
## |worry.mc:insomnia | 11| 15727.97| 15793.18| -7852.986| 15705.97| 3.534| 1| 0.060|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. TotalSteps1000.mc : = 0
## - TotalSteps1000.mc vs. null model = 1
## - weekday.sleep = 0.759
## - BMI.gmc = 0.916
## - sex = 0.968
## - worry.mc = 0.263
## - w.nd.mc = 0.097
## - insomnia = 0.351
## - worry.mc:insomnia = 0.43
## Selected model: worry.mc:insomnia
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |61.54(0.81) |75.92 |61.54(0.81) |75.92 |63.16(1.04) |60.68 |
## |3 |TotalSteps1000.mc |0.15(0.02) |7.59 |0.15(0.02) |7.60 |0.15(0.02) |7.63 |
## |4 |weekday.sleep [weekend] |0.35(0.17) |2.04 |0.35(0.17) |2.05 |0.34(0.17) |2.01 |
## |5 |BMI.gmc |0.55(0.20) |2.73 |0.55(0.20) |2.73 |0.47(0.20) |2.33 |
## |6 |sex [M] |-4.26(1.38) |-3.08 |-4.26(1.38) |-3.08 |-4.41(1.34) |-3.29 |
## |7 |worry.mc |-0.01(0.08) |-0.08 |-0.01(0.09) |-0.16 |-0.17(0.12) |-1.45 |
## |10 |w.nd.mc | | |0.04(0.09) |0.44 |0.04(0.09) |0.44 |
## |11 |insomnia [1] | | | | |-3.07(1.29) |-2.37 |
## |12 |worry.mc * insomnia [1] | | | | |0.31(0.17) |1.88 |
## |13 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |14 |Observations |2773 |2773 |2773 |NA |NA |NA |
## |8 |SD (Intercept) |6.15(NA) | |6.15(NA) | |5.96(NA) | |
## |9 |SD (Observations) |1.96(NA) | |1.96(NA) | |1.96(NA) | |
##
##
## - Plotting effect(s) estimated by model 8
##
##
##
## ###########################################
## Analyzing HR_NREM by mood
## ###########################################
##
## Running GLMER analysis of HR_NREM ...
##
## Preparing data...
## - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering TotalSteps1000 , mood , m.nd
##
## Model specification:
## - model M0 (null): HR_NREM ~ (1|ID)
## - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
## - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
## - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
## - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + (mood.mc|ID)
## - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + (mood.mc|ID)
## - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + insomnia + (mood.mc|ID)
## - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (mood.mc|ID)
##
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 15802.17| 15819.95| -7898.084| 15796.17| NA| NA| NA|
## |TotalSteps1000.mc | 4| 15743.78| 15767.50| -7867.892| 15735.78| 60.384| 1| 0.000|
## |weekday.sleep | 5| 15741.49| 15771.13| -7865.746| 15731.49| 4.293| 1| 0.038|
## |BMI.gmc | 6| 15736.16| 15771.73| -7862.082| 15724.16| 7.328| 1| 0.007|
## |sex | 7| 15729.16| 15770.65| -7857.577| 15715.16| 9.009| 1| 0.003|
## |mood.mc | 10| 15734.99| 15794.26| -7857.493| 15714.99| 0.169| 3| 0.982|
## |m.nd.mc | 11| 15731.43| 15796.64| -7854.718| 15709.43| 5.550| 1| 0.018|
## |insomnia | 12| 15727.87| 15799.00| -7851.935| 15703.87| 5.566| 1| 0.018|
## |mood.mc:insomnia | 13| 15729.28| 15806.34| -7851.641| 15703.28| 0.588| 1| 0.443|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. TotalSteps1000.mc : = 0
## - TotalSteps1000.mc vs. null model = 1
## - weekday.sleep = 0.759
## - BMI.gmc = 0.916
## - sex = 0.968
## - mood.mc = 0.05
## - m.nd.mc = 0.227
## - insomnia = 0.575
## - mood.mc:insomnia = 0.221
## Selected model: insomnia
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |61.54(0.81) |75.92 |61.54(0.81) |75.92 |63.15(1.04) |60.68 |
## |3 |TotalSteps1000.mc |0.15(0.02) |7.53 |0.15(0.02) |7.59 |0.15(0.02) |7.61 |
## |4 |weekday.sleep [weekend] |0.34(0.17) |2.04 |0.36(0.17) |2.12 |0.36(0.17) |2.12 |
## |5 |BMI.gmc |0.55(0.20) |2.73 |0.55(0.20) |2.73 |0.47(0.20) |2.33 |
## |6 |sex [M] |-4.25(1.38) |-3.08 |-4.25(1.38) |-3.07 |-4.40(1.34) |-3.28 |
## |7 |mood.mc |-0.03(0.09) |-0.36 |-0.05(0.09) |-0.58 |-0.12(0.13) |-0.95 |
## |12 |m.nd.mc | | |0.20(0.09) |2.36 |0.20(0.09) |2.38 |
## |13 |insomnia [1] | | | | |-3.07(1.29) |-2.37 |
## |14 |mood.mc * insomnia [1] | | | | |0.13(0.17) |0.77 |
## |15 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |16 |Observations |2773 |2773 |2773 |NA |NA |NA |
## |8 |SD (Intercept) |6.15(NA) | |6.15(NA) | |5.96(NA) | |
## |9 |SD (mood.mc) |0.12(NA) | |0.11(NA) | |0.10(NA) | |
## |11 |SD (Observations) |1.96(NA) | |1.96(NA) | |1.96(NA) | |
## |10 |Cor (Intercept~ID) |0.05(NA) | |0.15(NA) | |0.34(NA) | |
##
##
## - Plotting effect(s) estimated by model 8
##
##
##
## ###########################################
## Analyzing HR_NREM by PsyDist
## ###########################################
##
## Running GLMER analysis of HR_NREM ...
##
## Preparing data...
## - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering TotalSteps1000 , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): HR_NREM ~ (1|ID)
## - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
## - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
## - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
## - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + (PsyDist.mc|ID)
## - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 15802.17| 15819.95| -7898.084| 15796.17| NA| NA| NA|
## |TotalSteps1000.mc | 4| 15743.78| 15767.50| -7867.892| 15735.78| 60.384| 1| 0.000|
## |weekday.sleep | 5| 15741.49| 15771.13| -7865.746| 15731.49| 4.293| 1| 0.038|
## |BMI.gmc | 6| 15736.16| 15771.73| -7862.082| 15724.16| 7.328| 1| 0.007|
## |sex | 7| 15729.16| 15770.65| -7857.577| 15715.16| 9.009| 1| 0.003|
## |PsyDist.mc | 10| 15730.34| 15789.62| -7855.171| 15710.34| 4.813| 3| 0.186|
## |P.nd.mc | 11| 15731.33| 15796.53| -7854.663| 15709.33| 1.016| 1| 0.314|
## |insomnia | 12| 15727.25| 15798.38| -7851.625| 15703.25| 6.076| 1| 0.014|
## |PsyDist.mc:insomnia | 13| 15725.86| 15802.92| -7849.929| 15699.86| 3.392| 1| 0.066|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. TotalSteps1000.mc : = 0
## - TotalSteps1000.mc vs. null model = 1
## - weekday.sleep = 0.759
## - BMI.gmc = 0.916
## - sex = 0.968
## - PsyDist.mc = 0.348
## - P.nd.mc = 0.176
## - insomnia = 0.574
## - PsyDist.mc:insomnia = 0.535
## Selected model: PsyDist.mc:insomnia
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |61.53(0.81) |75.92 |61.53(0.81) |75.91 |63.15(1.04) |60.72 |
## |3 |TotalSteps1000.mc |0.15(0.02) |7.70 |0.15(0.02) |7.73 |0.16(0.02) |7.80 |
## |4 |weekday.sleep [weekend] |0.38(0.17) |2.21 |0.39(0.17) |2.28 |0.38(0.17) |2.26 |
## |5 |BMI.gmc |0.55(0.20) |2.71 |0.55(0.20) |2.71 |0.45(0.20) |2.26 |
## |6 |sex [M] |-4.24(1.38) |-3.07 |-4.24(1.38) |-3.07 |-4.39(1.34) |-3.29 |
## |7 |PsyDist.mc |0.06(0.13) |0.48 |0.03(0.13) |0.26 |-0.20(0.18) |-1.11 |
## |12 |P.nd.mc | | |0.11(0.11) |1.01 |0.12(0.11) |1.03 |
## |13 |insomnia [1] | | | | |-3.09(1.29) |-2.39 |
## |14 |PsyDist.mc * insomnia [1] | | | | |0.46(0.25) |1.86 |
## |15 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |16 |Observations |2773 |2773 |2773 |NA |NA |NA |
## |8 |SD (Intercept) |6.15(NA) | |6.15(NA) | |5.96(NA) | |
## |9 |SD (PsyDist.mc) |0.52(NA) | |0.53(NA) | |0.49(NA) | |
## |11 |SD (Observations) |1.96(NA) | |1.96(NA) | |1.96(NA) | |
## |10 |Cor (Intercept~ID) |0.07(NA) | |0.08(NA) | |0.24(NA) | |
##
##
## - Plotting effect(s) estimated by model 8
##
##
##
## ###########################################
## Analyzing HR_NREM by fs.w
## ###########################################
##
## Running GLMER analysis of HR_NREM ...
##
## Preparing data...
## - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Grand-mean-centering BMI
## - Mean-centering TotalSteps1000
##
## Model specification:
## - model M0 (null): HR_NREM ~ (1|ID)
## - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
## - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
## - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
## - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
## - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + (1|ID)
## - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + (1|ID)
## - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + insomnia + (1|ID)
## - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
##
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: fs.w:insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 15802.17| 15819.95| -7898.084| 15796.17| NA| NA| NA|
## |TotalSteps1000.mc | 4| 15743.78| 15767.50| -7867.892| 15735.78| 60.384| 1| 0.000|
## |weekday.sleep | 5| 15741.49| 15771.13| -7865.746| 15731.49| 4.293| 1| 0.038|
## |BMI.gmc | 6| 15736.16| 15771.73| -7862.082| 15724.16| 7.328| 1| 0.007|
## |sex | 7| 15729.16| 15770.65| -7857.577| 15715.16| 9.009| 1| 0.003|
## |fs.w | 8| 15730.94| 15778.36| -7857.472| 15714.94| 0.212| 1| 0.645|
## |f.nd | 9| 15731.67| 15785.02| -7856.836| 15713.67| 1.272| 1| 0.259|
## |insomnia | 10| 15728.22| 15787.50| -7854.111| 15708.22| 5.450| 1| 0.020|
## |fs.w:insomnia | 11| 15726.21| 15791.42| -7852.107| 15704.21| 4.008| 1| 0.045|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. TotalSteps1000.mc : = 0
## - TotalSteps1000.mc vs. null model = 1
## - weekday.sleep = 0.759
## - BMI.gmc = 0.916
## - sex = 0.968
## - fs.w = 0.284
## - f.nd = 0.165
## - insomnia = 0.48
## - fs.w:insomnia = 0.567
## Selected model: fs.w:insomnia
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |61.54(0.81) |75.92 |61.54(0.81) |75.93 |63.16(1.04) |60.67 |
## |3 |TotalSteps1000.mc |0.15(0.02) |7.61 |0.15(0.02) |7.64 |0.15(0.02) |7.73 |
## |4 |weekday.sleep [weekend] |0.36(0.17) |2.11 |0.37(0.17) |2.17 |0.36(0.17) |2.14 |
## |5 |BMI.gmc |0.55(0.20) |2.73 |0.55(0.20) |2.73 |0.47(0.20) |2.33 |
## |6 |sex [M] |-4.26(1.38) |-3.08 |-4.25(1.38) |-3.08 |-4.42(1.34) |-3.29 |
## |7 |fs.w |0.04(0.09) |0.46 |0.02(0.10) |0.19 |-0.18(0.14) |-1.31 |
## |10 |f.nd | | |0.11(0.10) |1.13 |0.11(0.10) |1.13 |
## |11 |insomnia [1] | | | | |-3.08(1.29) |-2.38 |
## |12 |fs.w * insomnia [1] | | | | |0.37(0.18) |2.00 |
## |13 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |14 |Observations |2773 |2773 |2773 |NA |NA |NA |
## |8 |SD (Intercept) |6.15(NA) | |6.15(NA) | |5.96(NA) | |
## |9 |SD (Observations) |1.96(NA) | |1.96(NA) | |1.96(NA) | |
##
##
## - Plotting effect(s) estimated by model 8
Comments:
both (1) residuals and (2) random effects are quite normally distributed, despite a marked deviation in the upper tail of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
TotalSteps1000, weekday.sleep, BMI, sex, insomnia, stress, next day mood, and the interactive terms (but not with mood) are associated with a significant LRT, whereas TotalSteps1000, weekday.sleep, BMI, sex, insomnia, stress, and the interactive term with stress, PsyDist, and fs showed stronger evidence in terms of Aw
in addition to the effects reported in section 5.1, a substantial positive effect is only estimated for next day mood, and by the interaction between insomnia and stress, worry, and fs
In section 5.1, HR_REM was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (higher HR_REM for later than usual SO), TotalSleep1000 (higher HR_NREM for higher than usual TotalSleep1000), sex (higher stageHR_TST in girls compared to boys), and the interaction between insomnia and sex (lower stageHR_TST in female insomnia compared to control insomnia). Contrarily to the other analyses, here sex is included (since it is an important predictor), while insomnia is added after diary ratings for better consistency. Note that the random slope for worry and mood is not included due to convergence problems.
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing HR_REM by",diaryVars[i],
"\n###########################################\n\n")
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
predictors <- c("SO.num","TotalSteps1000","sex",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","mood")){ ran.eff <- "(1|ID)" } # removing random slope for mood to reach convergence
keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""), # key predictors (M2, M3, and M4)
paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # selecting mean-centered pred. (not fs)
ran.eff <- gsub(".mc","",ran.eff)
keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# saving key results (considering M3 for mood, which showed higher Aw than M2 for all predictors)
key.model <- ifelse(diaryVars[i]=="mood",2,1)
res[[i]] <- rbind(res[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],messages=FALSE)))
res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
res.int[[i]] <- rbind(res.int[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",
fix.eff=predictors,ran.eff=ran.eff,gmc.predictors="BMI",
modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
# showing analysis
glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
outputs=outputs,ran.eff=ran.eff,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
##
##
##
## ###########################################
## Analyzing HR_REM by stress
## ###########################################
##
## Running GLMER analysis of HR_REM ...
##
## Preparing data...
## - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Mean-centering SO.num , TotalSteps1000 , stress , s.nd
##
## Model specification:
## - model M0 (null): HR_REM ~ (1|ID)
## - model M1: HR_REM ~ SO.num.mc + (1|ID)
## - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
## - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
## - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + (stress.mc|ID)
## - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + (stress.mc|ID)
## - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + insomnia + (stress.mc|ID)
## - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (stress.mc|ID)
##
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Plotting diagnostics of the most complex model:
##
## Printing Variance Inflation Factors (VIF):
## SO.num.mc TotalSteps1000.mc sex stress.mc
## 1.003840 1.007060 1.001511 2.067887
## s.nd.mc insomnia stress.mc:insomnia
## 1.037380 1.021541 2.066887
##
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 16007.69| 16025.49| -8000.846| 16001.69| NA| NA| NA|
## |SO.num.mc | 4| 16001.08| 16024.81| -7996.537| 15993.08| 8.617| 1| 0.003|
## |TotalSteps1000.mc | 5| 15960.73| 15990.40| -7975.364| 15950.73| 42.346| 1| 0.000|
## |sex | 6| 15954.63| 15990.23| -7971.315| 15942.63| 8.099| 1| 0.004|
## |stress.mc | 9| 15942.56| 15995.96| -7962.278| 15924.56| 18.073| 3| 0.000|
## |s.nd.mc | 10| 15944.15| 16003.48| -7962.074| 15924.15| 0.409| 1| 0.522|
## |insomnia | 11| 15938.97| 16004.24| -7958.486| 15916.97| 7.175| 1| 0.007|
## |stress.mc:insomnia | 12| 15940.28| 16011.48| -7958.141| 15916.28| 0.690| 1| 0.406|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.035
## - SO.num.mc vs. null model = 0.965
## - TotalSteps1000.mc = 1
## - sex = 0.955
## - stress.mc = 0.998
## - s.nd.mc = 0.31
## - insomnia = 0.805
## - stress.mc:insomnia = 0.295
## Selected model: insomnia
##
## - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |63.54(0.84) |75.72 |63.54(0.84) |75.72 |65.35(1.06) |61.71 |
## |3 |SO.num.mc |0.21(0.07) |3.01 |0.20(0.07) |2.97 |0.21(0.07) |2.99 |
## |4 |TotalSteps1000.mc |0.13(0.02) |6.62 |0.13(0.02) |6.58 |0.13(0.02) |6.63 |
## |5 |sex [M] |-4.20(1.43) |-2.94 |-4.20(1.43) |-2.94 |-4.35(1.37) |-3.18 |
## |6 |stress.mc |0.21(0.11) |2.01 |0.23(0.11) |2.09 |0.14(0.15) |0.91 |
## |11 |s.nd.mc | | |-0.05(0.08) |-0.64 |-0.06(0.08) |-0.66 |
## |12 |insomnia [1] | | | | |-3.44(1.31) |-2.62 |
## |13 |stress.mc * insomnia [1] | | | | |0.18(0.21) |0.84 |
## |14 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |15 |Observations |2789 |2789 |2789 |NA |NA |NA |
## |7 |SD (Intercept) |6.39(NA) | |6.39(NA) | |6.15(NA) | |
## |8 |SD (stress.mc) |0.56(NA) | |0.56(NA) | |0.55(NA) | |
## |10 |SD (Observations) |1.98(NA) | |1.97(NA) | |1.98(NA) | |
## |9 |Cor (Intercept~ID) |0.17(NA) | |0.18(NA) | |0.25(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing HR_REM by worry
## ###########################################
##
## Running GLMER analysis of HR_REM ...
##
## Preparing data...
## - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Mean-centering SO.num , TotalSteps1000 , worry , w.nd
##
## Model specification:
## - model M0 (null): HR_REM ~ (1|ID)
## - model M1: HR_REM ~ SO.num.mc + (1|ID)
## - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
## - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
## - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + (1|ID)
## - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + (1|ID)
## - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + insomnia + (1|ID)
## - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
##
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 16007.69| 16025.49| -8000.846| 16001.69| NA| NA| NA|
## |SO.num.mc | 4| 16001.08| 16024.81| -7996.537| 15993.08| 8.617| 1| 0.003|
## |TotalSteps1000.mc | 5| 15960.73| 15990.40| -7975.364| 15950.73| 42.346| 1| 0.000|
## |sex | 6| 15954.63| 15990.23| -7971.315| 15942.63| 8.099| 1| 0.004|
## |worry.mc | 7| 15956.05| 15997.58| -7971.023| 15942.05| 0.583| 1| 0.445|
## |w.nd.mc | 8| 15956.63| 16004.10| -7970.316| 15940.63| 1.414| 1| 0.234|
## |insomnia | 9| 15952.03| 16005.44| -7967.017| 15934.03| 6.598| 1| 0.010|
## |worry.mc:insomnia | 10| 15952.91| 16012.24| -7966.452| 15932.91| 1.130| 1| 0.288|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.035
## - SO.num.mc vs. null model = 0.965
## - TotalSteps1000.mc = 1
## - sex = 0.955
## - worry.mc = 0.32
## - w.nd.mc = 0.193
## - insomnia = 0.657
## - worry.mc:insomnia = 0.298
## Selected model: insomnia
##
## - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |63.53(0.84) |75.59 |63.53(0.84) |75.59 |65.33(1.06) |61.58 |
## |3 |SO.num.mc |0.19(0.07) |2.82 |0.20(0.07) |2.86 |0.20(0.07) |2.87 |
## |4 |TotalSteps1000.mc |0.13(0.02) |6.49 |0.13(0.02) |6.51 |0.13(0.02) |6.52 |
## |5 |sex [M] |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6 |worry.mc |-0.07(0.09) |-0.76 |-0.08(0.09) |-0.97 |-0.18(0.12) |-1.43 |
## |9 |w.nd.mc | | |0.10(0.09) |1.19 |0.10(0.09) |1.19 |
## |10 |insomnia [1] | | | | |-3.44(1.31) |-2.62 |
## |11 |worry.mc * insomnia [1] | | | | |0.18(0.17) |1.06 |
## |12 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |13 |Observations |2789 |2789 |2789 |NA |NA |NA |
## |7 |SD (Intercept) |6.39(NA) | |6.39(NA) | |6.14(NA) | |
## |8 |SD (Observations) |1.98(NA) | |1.98(NA) | |1.98(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing HR_REM by mood
## ###########################################
##
## Running GLMER analysis of HR_REM ...
##
## Preparing data...
## - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Mean-centering SO.num , TotalSteps1000 , mood , m.nd
##
## Model specification:
## - model M0 (null): HR_REM ~ (1|ID)
## - model M1: HR_REM ~ SO.num.mc + (1|ID)
## - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
## - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
## - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + (1|ID)
## - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + (1|ID)
## - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + insomnia + (1|ID)
## - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
##
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 16007.69| 16025.49| -8000.846| 16001.69| NA| NA| NA|
## |SO.num.mc | 4| 16001.08| 16024.81| -7996.537| 15993.08| 8.617| 1| 0.003|
## |TotalSteps1000.mc | 5| 15960.73| 15990.40| -7975.364| 15950.73| 42.346| 1| 0.000|
## |sex | 6| 15954.63| 15990.23| -7971.315| 15942.63| 8.099| 1| 0.004|
## |mood.mc | 7| 15955.71| 15997.24| -7970.854| 15941.71| 0.922| 1| 0.337|
## |m.nd.mc | 8| 15952.93| 16000.39| -7968.463| 15936.93| 4.782| 1| 0.029|
## |insomnia | 9| 15948.33| 16001.73| -7965.164| 15930.33| 6.598| 1| 0.010|
## |mood.mc:insomnia | 10| 15950.25| 16009.59| -7965.128| 15930.25| 0.073| 1| 0.787|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.035
## - SO.num.mc vs. null model = 0.965
## - TotalSteps1000.mc = 1
## - sex = 0.955
## - mood.mc = 0.358
## - m.nd.mc = 0.59
## - insomnia = 0.855
## - mood.mc:insomnia = 0.246
## Selected model: insomnia
##
## - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |63.53(0.84) |75.59 |63.53(0.84) |75.59 |65.33(1.06) |61.58 |
## |3 |SO.num.mc |0.19(0.07) |2.79 |0.19(0.07) |2.82 |0.19(0.07) |2.82 |
## |4 |TotalSteps1000.mc |0.13(0.02) |6.38 |0.13(0.02) |6.44 |0.13(0.02) |6.43 |
## |5 |sex [M] |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6 |mood.mc |-0.08(0.09) |-0.96 |-0.10(0.09) |-1.17 |-0.08(0.13) |-0.60 |
## |9 |m.nd.mc | | |0.19(0.09) |2.19 |0.19(0.09) |2.19 |
## |10 |insomnia [1] | | | | |-3.44(1.31) |-2.62 |
## |11 |mood.mc * insomnia [1] | | | | |-0.05(0.18) |-0.27 |
## |12 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |13 |Observations |2789 |2789 |2789 |NA |NA |NA |
## |7 |SD (Intercept) |6.39(NA) | |6.39(NA) | |6.14(NA) | |
## |8 |SD (Observations) |1.98(NA) | |1.98(NA) | |1.98(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing HR_REM by PsyDist
## ###########################################
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00329949 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00329949 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00329949 (tol = 0.002, component 1)
## Running GLMER analysis of HR_REM ...
##
## Preparing data...
## - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Mean-centering SO.num , TotalSteps1000 , PsyDist , P.nd
##
## Model specification:
## - model M0 (null): HR_REM ~ (1|ID)
## - model M1: HR_REM ~ SO.num.mc + (1|ID)
## - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
## - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
## - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + (PsyDist.mc|ID)
## - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + (PsyDist.mc|ID)
## - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + insomnia + (PsyDist.mc|ID)
## - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (PsyDist.mc|ID)
##
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00329949 (tol = 0.002, component 1)
##
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 16007.69| 16025.49| -8000.846| 16001.69| NA| NA| NA|
## |SO.num.mc | 4| 16001.08| 16024.81| -7996.537| 15993.08| 8.617| 1| 0.003|
## |TotalSteps1000.mc | 5| 15960.73| 15990.40| -7975.364| 15950.73| 42.346| 1| 0.000|
## |sex | 6| 15954.63| 15990.23| -7971.315| 15942.63| 8.099| 1| 0.004|
## |PsyDist.mc | 9| 15949.92| 16003.32| -7965.961| 15931.92| 10.707| 3| 0.013|
## |P.nd.mc | 10| 15950.34| 16009.67| -7965.168| 15930.34| 1.586| 1| 0.208|
## |insomnia | 11| 15945.07| 16010.34| -7961.536| 15923.07| 7.265| 1| 0.007|
## |PsyDist.mc:insomnia | 12| 15946.61| 16017.81| -7961.303| 15922.61| 0.465| 1| 0.495|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.035
## - SO.num.mc vs. null model = 0.965
## - TotalSteps1000.mc = 1
## - sex = 0.955
## - PsyDist.mc = 0.909
## - P.nd.mc = 0.425
## - insomnia = 0.855
## - PsyDist.mc:insomnia = 0.284
## Selected model: insomnia
##
## - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |63.56(0.84) |75.84 |63.56(0.84) |75.84 |65.37(1.06) |61.78 |
## |3 |SO.num.mc |0.21(0.07) |2.98 |0.21(0.07) |3.02 |0.21(0.07) |3.04 |
## |4 |TotalSteps1000.mc |0.13(0.02) |6.59 |0.13(0.02) |6.63 |0.14(0.02) |6.66 |
## |5 |sex [M] |-4.27(1.42) |-3.00 |-4.27(1.42) |-3.00 |-4.45(1.36) |-3.26 |
## |6 |PsyDist.mc |0.05(0.14) |0.35 |0.01(0.14) |0.09 |-0.09(0.21) |-0.42 |
## |11 |P.nd.mc | | |0.14(0.11) |1.26 |0.15(0.11) |1.27 |
## |12 |insomnia [1] | | | | |-3.44(1.31) |-2.63 |
## |13 |PsyDist.mc * insomnia [1] | | | | |0.19(0.28) |0.68 |
## |14 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |15 |Observations |2789 |2789 |2789 |NA |NA |NA |
## |7 |SD (Intercept) |6.39(NA) | |6.39(NA) | |6.14(NA) | |
## |8 |SD (PsyDist.mc) |0.72(NA) | |0.72(NA) | |0.72(NA) | |
## |10 |SD (Observations) |1.98(NA) | |1.98(NA) | |1.98(NA) | |
## |9 |Cor (Intercept~ID) |0.23(NA) | |0.24(NA) | |0.30(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
##
##
##
## ###########################################
## Analyzing HR_REM by fs.w
## ###########################################
##
## Running GLMER analysis of HR_REM ...
##
## Preparing data...
## - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
## and 3 participants with no complete variables
## - Mean-centering SO.num , TotalSteps1000
##
## Model specification:
## - model M0 (null): HR_REM ~ (1|ID)
## - model M1: HR_REM ~ SO.num.mc + (1|ID)
## - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
## - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
## - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + (fs.w|ID)
## - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + (fs.w|ID)
## - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + insomnia + (fs.w|ID)
## - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + insomnia + fs.w:insomnia + (fs.w|ID)
##
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants
## using the normal family with the identity link function using ML estimator...
##
## Generating models outputs...
##
## - Running likelihood ratio test:
## Selected model: insomnia
##
## | | npar| AIC| BIC| logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Null model | 3| 16007.69| 16025.49| -8000.846| 16001.69| NA| NA| NA|
## |SO.num.mc | 4| 16001.08| 16024.81| -7996.537| 15993.08| 8.617| 1| 0.003|
## |TotalSteps1000.mc | 5| 15960.73| 15990.40| -7975.364| 15950.73| 42.346| 1| 0.000|
## |sex | 6| 15954.63| 15990.23| -7971.315| 15942.63| 8.099| 1| 0.004|
## |fs.w | 9| 15952.78| 16006.18| -7967.391| 15934.78| 7.847| 3| 0.049|
## |f.nd | 10| 15952.41| 16011.74| -7966.204| 15932.41| 2.375| 1| 0.123|
## |insomnia | 11| 15947.11| 16012.38| -7962.555| 15925.11| 7.297| 1| 0.007|
## |fs.w:insomnia | 12| 15948.65| 16019.85| -7962.325| 15924.65| 0.460| 1| 0.497|
##
##
## - Computing Aw coefficients for each model vs. all previous models:
## - null model vs. SO.num.mc : = 0.035
## - SO.num.mc vs. null model = 0.965
## - TotalSteps1000.mc = 1
## - sex = 0.955
## - fs.w = 0.706
## - f.nd = 0.46
## - insomnia = 0.867
## - fs.w:insomnia = 0.286
## Selected model: insomnia
##
## - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
##
## | |Predictors |B (SE) |t |B (SE) |t |B (SE) |t |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2 |(Intercept) |63.56(0.84) |75.82 |63.56(0.84) |75.85 |65.37(1.06) |61.80 |
## |3 |SO.num.mc |0.20(0.07) |2.96 |0.21(0.07) |3.01 |0.21(0.07) |3.03 |
## |4 |TotalSteps1000.mc |0.13(0.02) |6.55 |0.13(0.02) |6.59 |0.13(0.02) |6.62 |
## |5 |sex [M] |-4.26(1.42) |-3.00 |-4.25(1.42) |-2.99 |-4.43(1.36) |-3.25 |
## |6 |fs.w |0.01(0.12) |0.06 |-0.03(0.12) |-0.25 |-0.11(0.17) |-0.65 |
## |11 |f.nd | | |0.15(0.10) |1.54 |0.15(0.10) |1.55 |
## |12 |insomnia [1] | | | | |-3.45(1.31) |-2.63 |
## |13 |fs.w * insomnia [1] | | | | |0.16(0.23) |0.68 |
## |14 |N |90 ID |90 ID |90 ID |NA |NA |NA |
## |15 |Observations |2789 |2789 |2789 |NA |NA |NA |
## |7 |SD (Intercept) |6.39(NA) | |6.39(NA) | |6.14(NA) | |
## |8 |SD (fs.w) |0.56(NA) | |0.56(NA) | |0.55(NA) | |
## |10 |SD (Observations) |1.98(NA) | |1.98(NA) | |1.98(NA) | |
## |9 |Cor (Intercept~ID) |0.25(NA) | |0.26(NA) | |0.33(NA) | |
##
##
## - Plotting effect(s) estimated by model 7
Comments:
both (1) residuals and (2) random effects are quite normally distributed, despite a marked deviation in the upper tail of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less
SO.num, TotalSteps1000, sex, insomnia, stress, PsyDist, fs, and next day mood are associated with a significant LRT, whereas SO.num, TotalSteps1000, sex, insomnia, stress, PsyDist, fs, and next day stress, PsyDist, and fs showed stronger evidence in terms of Aw
in addition to the effects reported in section 5.1, a substantial positive effect is only estimated for stress and next day mood
Here, we use the key.resPlot function to graphically summarize the results obtained from the models above. The figure below shows the t-values associated with the `*diary ratings preceding the sleep periods by considering either model M2 (main effect of previous day diary ratings) or model M3 (main effect of the next day diary ratings**). The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, and |t| > 1.96 ) are shown in green
those relationships showing a |t| > 1.96 but either a nonsignificant LRT or a lower Aw than the previous model are shown in light green (or lime)
those showing a |t| > 1.96 but both nonsignificant LRT and lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT or a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT and lower Aw than the previous models are shown in red
# all results in one data.frame
RES <- rbind(cbind(res[[1]],pred=rep("stress",16)),cbind(res[[2]],pred=rep("worry",16)),
cbind(res[[3]],pred=rep("mood",16)),cbind(res[[4]],pred=rep("PsyDist",16)),
cbind(res[[5]],pred=rep("fs.w",16)))
RES$pred <- factor(RES$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))
# stress
key.resPlot(RES,robCheck="pred")
Comments:
the analysis of the relationships between sleep outcomes and diary ratings highlighted substantial negative relationships between previous day diary ratings and TIB (negatively related to all ratings), TST and WakeUp.num (related to all ratings but mood), WASO (only substantially related with worry and PsyDist), and SO.num (only insubstantially related to stress)
a substantial positive relationship is also observed between stress and HR_REM
# all results in one data.frame
RES.nd <- rbind(cbind(res.nd[[1]],pred=rep("stress",16)),cbind(res.nd[[2]],pred=rep("worry",16)),
cbind(res.nd[[3]],pred=rep("mood",16)),cbind(res.nd[[4]],pred=rep("PsyDist",16)),
cbind(res.nd[[5]],pred=rep("fs.w",16)))
RES.nd$pred <- factor(RES.nd$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))
# stress
key.resPlot(RES.nd,robCheck="pred")
Comments:
the analysis of the relationships between sleep outcomes and next day diary ratings highlighted substantial negative relationships between the next day stress ratings and TIB, TST, WASO, and WakeUp.num
WakeUp.num.SSD is negatively associated with all next day ratings (although the relationship with worry is not supported by the Aw)
TIB.SSD and TST.SSD only show some substantial negative relationships with next day PsyDist
next day mood ratings show a negative relationship with TST.SSD, and a positive relationship with both HR_NREM, and HR_REM, although some of them was not supported by higher Aw than the previous model
# all results in one data.frame
RES.int <- rbind(cbind(res.int[[1]],pred=rep("stress",16)),cbind(res.int[[2]],pred=rep("worry",16)),
cbind(res.int[[3]],pred=rep("mood",16)),cbind(res.int[[4]],pred=rep("PsyDist",16)),
cbind(res.int[[5]],pred=rep("fs.w",16)))
RES.int$pred <- factor(RES.int$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))
# stress
key.resPlot(RES.int,robCheck="pred")
Comments:
the analysis of the interactive model highlighted substantial interactions between insomnia and stress, worry, and fs only in predicting HR_NREM (i.e., stronger positive relationship between diary ratings and HR_NREM in insomnia compared to controls)
none of the other sleep outcomes are substantially predicted by the interactive terms
Here, we conduct several robustness checks to account for the arbitrariness of our data processing and analytical choices, including (1) the consideration of insomnia.group instead of the insomnia variable, (2) the inclusion of the covid19 variable as a further covariate, (3) the exclusion of participants with extreme missing data, (4) the exclusion of TotalSteps1000, (5) the use of alternative family distributions for the analyses.
In addition to the glmerAn and the keyResPlot functions reported in section 5.1.6, we also use the predSelect function to select the covariates of each sleep outcome, based on the results in section 5.1.
predSelect <- function(sleepVar){
# SE, deep.p, and rem.p were only predicted by SO.num
if(sleepVar%in%c("SE","deep.p","rem.p")){
predictors <- c("SO.num")
# SO.num.SSDc and WakeUp.num.SSDc were only predicted by weekday.sleep
} else if(sleepVar%in%c("SO.num.SSDc","WakeUp.num.SSDc")){
predictors <- "weekday.sleep"
# light.p was only predicted by BMI
} else if(sleepVar=="light.p"){
predictors <- "BMI"
# SO.num, TIB.SSDc, and TST.SSDc were predicted by weekday.sleep and BMI
} else if(sleepVar%in%c("SO.num","TIB.SSDc","TST.SSDc")){
predictors <- c("weekday.sleep","BMI")
# WakeUp.num was predicted by SO.num, weekday.sleep, and BMI
} else if(sleepVar=="WakeUp.num"){
predictors <- c("SO.num","weekday.sleep","BMI")
# HR_NREM was predicted by TotalSteps1000, weekday.sleep, BMI, and sex
} else if(sleepVar=="HR_NREM"){
predictors <- c("TotalSteps1000","weekday.sleep","BMI","sex")
# HR_NREM was predicted by SO.num, TotalSteps1000, and sex
} else if(sleepVar=="HR_REM"){
predictors <- c("SO.num","TotalSteps1000","sex")
# all remaining sleep outcomes were predicted by SO.num and weekday.sleep
} else { predictors <- c("SO.num","weekday.sleep") }
return(predictors)}
Here, we inspect the results on the interactive term obtained by considering the insomnia.group (i.e., 46 controls, 26 DSM.ins and 21 sub.ins) rather than the insomnia variable (i.e., 46 controls vs. 47 insomnia).
The figure below shows the t-values associated with the interactive term for each sleep outcome and diary predictor, by considering model M4 (interactive model). The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Note that the random slope for stress on SO.num, that for worry on WASO, and that for fs on WakeUp.num, WASO.SSD, and HR_NREM were not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia.group",paste(diaryVars[i],"insomnia.group",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(diaryVars[i],".mc:insomnia.group",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
sleepVars <- c(s.archit[2:length(s.archit)],s.timing,paste(s.variab,"c",sep=""),s.auton)
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
key <- paste(diaryVars[i],":insomnia.group",sep="")
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia.group",key)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" |
(diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","SO.num")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","WASO")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("WakeUp.num","WASO.SSDc","HR_NREM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
key <- paste(diaryVars[i],".mc:insomnia.group",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00351926 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00329949 (tol = 0.002, component 1)
# plotting robustness check
RES.int <- list()
for(i in 1:length(res.int)){
res.int[[i]]$robCheck <- "Original"
res2[[i]]$robCheck <- "insomnia.group"
RES.int[[i]] <- rbind(res.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]],robCheck = "robCheck") + ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }
Comments:
results are highly consistent with the main analyses for most sleep outcomes
the only difference is that even the interactions on HR_NREM are not substantial, and that worry is now substantially associated with both TIB.SSD and TST.SSD
Here, we inspect the results obtained by including the covid19 variable as a further covariate. As shown in section 1.2.8, the covid19 factor discriminates the data collected pre-COVID19 (63%) and the data collected post-COVID19 (37%). The covariate is included at the first step (model M1, before the first predictor).
The figures below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Separate robustness checks are conducted for each effect of interest.
Note that the random slope for stress on HR_NREM, that of worry on rem.p, and that of fs.w on rem.p are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
key.pred <- paste(diaryVars[i],".mc",sep="") # selecting target predictor (previous day ratings) and target model (M2 or M3)
if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
key.model <- paste(nd,".mc",sep="") # selecting model including next day day rating
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd)
# selecting target predictor (previous day rating) and target model (M2 or M3 based on above)
key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (previous day rating)
if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress" & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
(diaryVars[i]=="mood" & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".")
} else { key.model <- paste(diaryVars[i],"mc",sep=".") }
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","HR_NREM")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","rem.p")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("rem.p"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",
key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}
# plotting robustness check
RES.pd <- list()
for(i in 1:length(res)){
res[[i]]$robCheck <- "Original"
res2[[i]]$robCheck <- "covid19"
RES.pd[[i]] <- rbind(res[[i]],res2[[i]])
print(key.resPlot(RES.pd[[i]],robCheck = "robCheck") + ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are highly consistent with the main analyses
the only difference is highlighted for SO.num (showing no longer substantial relationship with worry)
Note that the random slope for stress on HR_NREM, that of worry on rem.p, and that of fs.w on rem.p are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(nd,".mc",sep="") # selecting model including next day day rating
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd)
key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","rem.p","HR_NREM")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","rem.p")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("rem.p"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
RES.nd <- list()
for(i in 1:length(res)){
res.nd[[i]]$robCheck <- "Original"
res2[[i]]$robCheck <- "covid19"
RES.nd[[i]] <- rbind(res.nd[[i]],res2[[i]])
print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","covid19"),],
robCheck = "robCheck") + ggtitle(paste("Next day",diaryVars[i]))) }
Comments:
In conclusion, the results of this robustness check were highly consistent with those obtained with the main analyses, although questioning the generalizability of the relationships observed between next day PsyDist and WakeUp.num.
Note that the random slope for stress on TST, HR_NREM, that of Worry on rem.p, and that of fs on rem.p, and HR_NREM are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
key <- paste(diaryVars[i],":insomnia",sep="")
predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",key)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID) "}
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M4)
key <- paste(diaryVars[i],":insomnia",sep="")
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",key)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","rem.p","HR_NREM","TST")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","rem.p")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("SE","rem.p")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("rem.p","HR_NREM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "covid19"
RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","covid19"),],robCheck = "robCheck") +
ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }
Comments:
results are overall consistent with the main analyses for most sleep outcomes
the main difference is that the interactive term for PsyDist is substantial on HR_NREM with the inclusion of covid19 as a further covariate
Here, we inspect the results obtained by excluding seven participants (7.5%) with less than two weeks of valid observations in any data type. In section 3.2, these participants were marked with majMiss = 1.
The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Separate robustness checks are conducted for each effect of interest.
Note that the random slope for stress on TST, that for worry on WASO, that for PsyDist on SE and light.p, and that of fs on light.p and HR_REM are not included due to convergence problems, in addition to the random slopes excluded above.
# excluding participants with extreme missing data
EMA <- ema[ema$majMiss!=1,]
DEMOS <- demos[demos$ID%in%levels(as.factor(as.character(EMA$ID))),]
cat("Excluded",nrow(ema)-nrow(EMA),"days, ",nrow(demos)-nrow(DEMOS),"participants")
## Excluded 465 days, 7 participants
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
# selecting target predictor (previous day rating) and target model (M2 or M3 based on above)
key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (previous day rating)
if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress" & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
(diaryVars[i]=="mood" & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".")
} else { key.model <- paste(diaryVars[i],"mc",sep=".") }
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","TST")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","WASO")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM","SE","light.p"))|
(diaryVars[i]=="fs.w" & sleepVar%in%c("light.p","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",
key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00295246 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "majMiss"
RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses
the main differences are highlighted for mood, whose relationship with TIB is no longer substantial after the exclusion of participants with majMiss
similarly, the relationship between worry and SO.num is no longer substantial
Note that the random slope for stress on TST, that for worry on WASO, that for PsyDist on SE and light.p, and that of fs on light.p and HR_REM are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(nd,".mc",sep="") # selecting model including next day day rating
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","TST")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","WASO")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM","SE","light.p"))|
(diaryVars[i]=="fs.w" & sleepVar%in%c("light.p","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") } # selecting family distribution
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00295246 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "majMiss"
RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") +
ggtitle(paste("Next day",diaryVars[i]))) }
Comments:
results are overall consistent with the main analyses
the main differences are highlighted for TST.SSD (showing no longer substantial relationship with next day mood), TIB.SSD (showing no longer substantial relationship with next day PsyDist), and WakeUp.num.SSDc (showing no longer substantial relationship with next day stress)
Note that the random slope for stress on TST, that for worry on WASO and rem.p, that for mood on HR_NREM, that for PsyDist on SE and light.p, and that of fs on light.p and HR_REM are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
key <- paste(diaryVars[i],":insomnia",sep="")
predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",key)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M4)
key <- paste(diaryVars[i],":insomnia",sep="")
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",key)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","TST")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM","WASO","rem.p")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM","HR_NREM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM","SE","light.p"))|
(diaryVars[i]=="fs.w" & sleepVar%in%c("light.p","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00295246 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00224979 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00275379 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "majMiss"
RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") +
ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }
Comments:
results are overall consistent with the main analyses
the only difference is that the interactions between insomnia and worry on both rem.p and HR_REM are no longer substantial (although nor really diminished) after the exclusion of majMiss participants
Here, we inspect the results obtained by excluding TotalSteps1000 from the models predictors. This is done in order to replicate the analyses by including cases with invalid daily steps data (thus, with higher sample size). Note that for these analyses, TotalSteps1000 was only included in HR_NREM models.
The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Separate robustness checks are conducted for each effect of interest.
Note that the random slope for mood is not included due to convergence problems, in addition to the random slopes removed above.
# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","mood","PsyDist")){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(diaryVars[i]=="mood"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- key.pred } # model M3 only for mood
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c(diaryVars[i],nd) }
# updating results
res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00784235 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00470773 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "no-TotalSteps"
RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are overall consistent with the main analyses
the only difference is that stress now shows a substantial positive relationship with HR_NREM
Note that the random slope for mood is not included due to convergence problems.
# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","mood","PsyDist")){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(nd,".mc",sep="") # next day rating
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c(diaryVars[i],nd) }
res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00784235 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00470773 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "no-TotalSteps"
RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") +
ggtitle(paste("Next day day",diaryVars[i]))) }
Comments:
Note that the random slope for mood is not included due to convergence problems.
# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
key <- paste(diaryVars[i],":insomnia",sep="")
predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd,"insomnia",key)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("worry","mood","PsyDist")){ ran.eff <- "(1|ID)" } # removing random slopes due to convergence problems
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c(diaryVars[i],nd) }
res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00784235 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00470773 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "no-TotalSteps"
RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") +
ggtitle(paste("Next day day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses: the interaction between insomnia and both worry and fs are no longer substantial
in contrast, the interaction between insomnia and PsyDist becomes substantial with the removal of TotalSteps1000
Here, we replicate the models predicting those variables that showed poor fit in the model diagnostics above by re-specifying the models with different distribution families and link functions. As done in section 5.1.6.6, we model:
WASO and both s.auton outcomes by using the gamma distribution
all s.variab outcomes by assuming a normal distribution
The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Separate robustness checks are conducted for each effect of interest.
Note that the random slope for worry on SO.num.SSD, that for mood and PsyDist on TIB.SSD, TST.SSD, and SO.num.SSD, that of fs on TIB.SSD and SO.num.SSD, and all random slopes on WASO.SSD and WakeUp.num.SSD are not included due to convergence problems. Moreover, the model predicting TIB.SSD by fs does not converge even when excluding its random slope.
# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" }
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
family="gamma",link="log", # gamma with log link function
mc.predictors=mc.predictors,
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE,
nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (previous day rating) and target model (M2 or M3 based on above)
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(sleepVar=="WakeUp.num.SSDc" | (sleepVar=="TIB.SSDc" & diaryVars[i]=="PsyDist") |
(sleepVar=="TST.SSDc" & diaryVars[i]%in%c("mood","PsyDist","fs.w"))){ key.model <- paste(nd,"mc",sep=".")
} else { key.model <- paste(diaryVars[i],"mc",sep=".") }
# removing random slopes for those models showing convergence problems
if(sleepVar%in%c("WASO.SSDc","WakeUp.num.SSDc") |
(diaryVars[i]=="worry" & sleepVar=="SO.num.SSDc") |
(diaryVars[i]%in%c("mood","PsyDist") & sleepVar%in%c("TIB.SSDc","TST.SSDc","SO.num.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("TIB.SSDc","SO.num.SSDc"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# updating results
if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge even without random slope
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="normal",link="identity", # normal with identity funct
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00206693 (tol = 0.002, component 1)
# computing key results for s.auton
for(sleepVar in s.auton){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (previous day rating) and target model (M2 or M3 based on above)
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(diaryVars[i]=="mood"){ key.model <- paste(nd,"mc",sep=".") } else { key.model <- paste(diaryVars[i],"mc",sep=".") }
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log", # normal with identity funct
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE,
nAGQ=0))) }} # nAGQ = 0 to reach convergence
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "familyDistr"
RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are overall consistent with the main analyses
the main differences are highlighted for stress, whose relationship with WASO becomes substantial when modeled by assuming a gamma distribution for residuals, whereas its relationship with HR_REM becomes not substantial when modeled with the same assumption
Note that the random slope for worry on SO.num.SSD, that for mood and PsyDist on TIB.SSD, TST.SSD, and SO.num.SSD, that of fs on TIB.SSD and SO.num.SSD, and all random slopes on WASO.SSD and WakeUp.num.SSD are not included due to convergence problems. Moreover, the model predicting TIB.SSD by fs does not converge even when excluding its random slope.
# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
# selecting predictors (model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="stress"){ ran.eff <- "(1|ID)" }
key <- paste(nd,".mc",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
family="gamma",link="log",mc.predictors=mc.predictors, # gamma with log link function
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
for(i in 1:length(diaryVars)){
# selecting predictors (model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (next day rating) and target model (M3)
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
key <- paste(nd,".mc",sep="")
# removing random slopes for those models showing convergence problems
if(sleepVar%in%c("WASO.SSDc","WakeUp.num.SSDc") |
(diaryVars[i]=="worry" & sleepVar=="SO.num.SSDc") |
(diaryVars[i]%in%c("mood","PsyDist") & sleepVar%in%c("TIB.SSDc","TST.SSDc","SO.num.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("TIB.SSDc","SO.num.SSDc"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# updating results
if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge even without random slope
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="normal",link="identity", # normal with identity funct
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00206693 (tol = 0.002, component 1)
# computing key results for s.auton
for(sleepVar in s.auton){
for(i in 1:length(diaryVars)){
# selecting predictors (model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (next day rating) and target model (M3)
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
key <- paste(nd,"mc",sep=".")
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log", # normal with identity funct
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
nAGQ=0))) }} # nAGQ = 0 to reach convergence
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "familyDistr"
RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses
the main differences are highlighted for s.variab outcomes, with no longer substantial relationships between next day worry and WakeUp.num.SSD, between next day PsyDist and both TIB.SSD and TST.SSD, and between next day fs and TST.SSD when modeled by assuming a normal distribution for residuals
Note that the random slope for worry on SO.num.SSD, that for mood and PsyDist on TIB.SSD, TST.SSD, and SO.num.SSD, that of fs on TIB.SSD and SO.num.SSD, and all random slopes on WASO.SSD and WakeUp.num.SSD are not included due to convergence problems. Moreover, the model predicting TIB.SSD by fs does not converge even when excluding its random slope.
# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
# selecting predictors (model M4)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
key <- paste(diaryVars[i],".mc:insomnia",sep="")
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,gsub(".mc","",key))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# updating results
res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
family="gamma",link="log", # gamma with log link function
mc.predictors=mc.predictors,
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
for(i in 1:length(diaryVars)){
# selecting predictors (model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (next day rating) and target model (M4)
key <- paste(diaryVars[i],".mc:insomnia",sep="")
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,gsub(".mc","",key))
# removing random slopes for those models showing convergence problems
if(sleepVar%in%c("WASO.SSDc","WakeUp.num.SSDc") |
(diaryVars[i]=="worry" & sleepVar=="SO.num.SSDc") |
(diaryVars[i]%in%c("mood","PsyDist") & sleepVar%in%c("TIB.SSDc","TST.SSDc","SO.num.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("TIB.SSDc","SO.num.SSDc"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
# updating results
if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge even without random slope
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="normal",link="identity", # normal with identity funct
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00206693 (tol = 0.002, component 1)
# computing key results for s.auton
for(sleepVar in s.auton){
for(i in 1:length(diaryVars)){
# selecting predictors (model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
# selecting target predictor (next day rating) and target model (M4)
key <- paste(diaryVars[i],".mc:insomnia",sep="")
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,gsub(".mc","",key))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family="gamma",link="log", # normal with identity funct
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
nAGQ=0))) }} # nAGQ = 0 to reach convergence
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "familyDistr"
RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses
the main difference is is that the interaction between insomnia and both worry and fs are no longer substantial (similarly to what resulted in section 5.3.6.5), whereas the interaction with stress is still substantial although not supported by the Aw
Here, we inspect the results obtained by excluding 1,010 cases (25.5%) in which participants filled the diary on the following day. In section 1.2.6, these cases were marked with diary.nextDay = 1.
The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
Separate robustness checks are conducted for each effect of interest.
Note that the random slope for mood on TIB, rem.p, and HR_NREM, and that of fs on WASO.SSD, HR_NREM, and HR_REM are not included due to convergence problems, in addition to the random slopes excluded above.
# excluding cases with diary responses in the next day
EMA <- ema[ema$diary.nextDay!=1,]
DEMOS <- demos[demos$ID%in%levels(as.factor(as.character(EMA$ID))),]
cat("Excluded",nrow(ema)-nrow(EMA),"days,",nrow(demos)-nrow(DEMOS),"participants")
## Excluded 1010 days, 0 participants
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") # random slope for diary rating at day i
if(diaryVars[i]%in%c("stress","mood")){ ran.eff <- "(1|ID)" } # removing random slope for mood to reach convergence
key.pred <- paste(diaryVars[i],".mc",sep="") # previous day rating
if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
# selecting target predictor (previous day rating) and target model (M2 or M3 based on above)
key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (previous day rating)
if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress" & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
(diaryVars[i]=="mood" & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
(diaryVars[i]=="fs.w" & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".")
} else { key.model <- paste(diaryVars[i],"mc",sep=".") }
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM","rem.p","HR_NREM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("WASO.SSDc","HR_NREM","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key.pred <- gsub(".mc","",key.pred)
key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",
key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "lateResp"
RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses
the main differences are highlighted for mood, whose relationships with TIB is no longer substantial after the exclusion of participants with majMiss, similarly to the results in section 5.3.6.3.
Note that the random slope for mood on TIB, rem.p, and HR_NREM, and that of fs on WASO.SSD, HR_NREM, and HR_REM are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
key <- paste(nd,".mc",sep="") # selecting model including next day day rating
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="")
if(diaryVars[i]%in%c("stress","mood")){ ran.eff <- "(1|ID)" }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M3)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM","rem.p","HR_NREM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("WASO.SSDc","HR_NREM","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") } # selecting family distribution
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "lateResp"
RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") +
ggtitle(paste("Previous day",diaryVars[i]))) }
Comments:
results are partially inconsistent with the main analyses
with the exclusion of **late responses, **next day**stressis now negatively related withSO.num,TIB.SSDc, andTST.SSD`
in contrast, next day mood is no longer substantially associated with both TST.SSD and HR_NREM
a few unsubstantial changes are observed also for the relationships between next day fs and both TIB.SSD and TST.SSD
Note that the random slope for stress on HR_NREM and HR_REM, that of mood on TIB, rem.p, and HR_NREM, and that of fs on WASO.SSD, HR_NREM, and HR_REM, are not included due to convergence problems, in addition to the random slopes excluded above.
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
key <- paste(diaryVars[i],".mc:insomnia",sep="")
ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="")
if(diaryVars[i]%in%c("stress","mood")){ ran.eff <- "(1|ID)" }
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,ran.eff=ran.eff,modelType=c("GLMER"),
mc.predictors=mc.predictors,gmc.predictors="BMI",
outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00206653 (tol = 0.002, component 1)
# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
for(i in 1:length(diaryVars)){
# selecting predictors (up to model M4)
nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
# removing random slopes for those models showing convergence problems
if(sleepVar=="deep.p" | (diaryVars[i]=="stress" & sleepVar%in%c("rem.p","WakeUp.num","HR_NREM","HR_REM")) |
(diaryVars[i]=="worry" & sleepVar%in%c("SE","light.p","deep.p","HR_NREM","HR_REM")) |
(diaryVars[i]=="mood") & sleepVar%in%c("TST","WASO","SE","deep.p","WakeUp.num","HR_REM","rem.p","HR_NREM") |
(diaryVars[i]=="PsyDist" & sleepVar%in%c("deep.p","rem.p","HR_NREM","HR_REM")) |
(diaryVars[i]=="fs.w" & sleepVar%in%c("WASO.SSDc","HR_NREM","HR_REM"))){ ran.eff <- "(1|ID)"
} else { ran.eff <- paste("(",diaryVars[i],".mc|ID)",sep="") }
key <- paste(diaryVars[i],".mc:insomnia",sep="")
if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
ran.eff <- gsub(".mc","",ran.eff)
key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
# selecting family distribution
if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
# updating results
res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,ran.eff=ran.eff,nAGQ=0,
modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00301707 (tol = 0.002, component 1)
# plotting robustness check
for(i in 1:length(res)){
res2[[i]]$robCheck <- "lateResp"
RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") +
ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }
Comments:
results are overall consistent with the main analyses
the only difference is that with the removal of lateResp the interaction between insomnia and mood on WASO.SSDc, and that between insomnia and PsyDist on HR_NREM become substantial
in contrast, the interaction with worry on rem.p is strongly diminished, becoming not substantial
Here, we summarize the results from all robustness checks. The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM). The figure uses the following color code:
substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green
those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)
those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow
those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange
those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red
The robustness checks are separately visualized for each effect of interest.
# stress
key.resPlot(RES.pd[[1]],robCheck = "robCheck")
# worry
key.resPlot(RES.pd[[2]],robCheck = "robCheck")
# mood
key.resPlot(RES.pd[[3]],robCheck = "robCheck")
# PsyDist
key.resPlot(RES.pd[[4]],robCheck = "robCheck")
# fs
key.resPlot(RES.pd[[5]],robCheck = "robCheck")
Comments:
the null results observed from the main analyses (especially on s.archit and s.variab) are highly consistent across the robustness checks
the most consistent effects are those of stress, worry, and PsyDist on TIB, TST, and WakeUp.num, in addition to the negative relationship between SO.num and both mood and PsyDist, and that between WASO and both worry and PsyDist
the positive relationship between stress and HR_REM is also relatively consistent, but diminished by the exclusion of lateResp and by the use of the gamma distribution
lower consistency is shown by the relationship between mood and TIB (not substantial in 2 out of 4 robustness checks), and that between worry and SO.num (not substantial in 2 out of 4)
In conclusion, the results obtained with the main analyses are quite robust, indicating consistent negative relationships between diary ratings and TIB, TST, WASO, SO.num, and WakeUp.num, in addition to a positive relationship between stress and HR_REM.
# stress
key.resPlot(RES.nd[[1]],robCheck = "robCheck")
# worry
key.resPlot(RES.nd[[2]],robCheck = "robCheck")
# mood
key.resPlot(RES.nd[[3]],robCheck = "robCheck")
# PsyDist
key.resPlot(RES.nd[[4]],robCheck = "robCheck")
# fs
key.resPlot(RES.nd[[5]],robCheck = "robCheck")
Comments:
the null results observed from the main analyses (especially on s.archit and s.variab) are highly consistent across the robustness checks
the most consistent effects are those of next day stress on TIB, TST, WASO, and WakeUp.num, those of mood on both HR_NREM and HR_REM, and those of all diary ratings on Wake.up.num.SSD
lower consistency is shown by the relationship between mood and TST.SSD (not substantial in 2 out of 5 robustness checks), and that between PsyDist and TIB.SSD (not substantial in 2 out of 5)
In conclusion, the results obtained with the main analyses are quite robust, indicating consistent negative relationships between next day stress and TIB, TST, WASO, and WakeUp.num, between mood and both HR_NREM and HR_REM, and between WakeUp.num.SSD and all diary ratings.
# stress
key.resPlot(RES.int[[1]],robCheck = "robCheck")
# worry
key.resPlot(RES.int[[2]],robCheck = "robCheck")
# mood
key.resPlot(RES.int[[3]],robCheck = "robCheck")
# PsyDist
key.resPlot(RES.int[[4]],robCheck = "robCheck")
# fs
key.resPlot(RES.int[[5]],robCheck = "robCheck")
Comments:
the null results observed from the main analyses are highly consistent across the robustness checks
the interaction between stress and insomnia on HR_NREM is quite consistent (substantial in 6 out of 7 robustness check)
lower consistency is shown by the interaction between insomnia and worry (substantial in 3 out of 7 robustness checks) and that with fs (substantial in 3 out of 7 robustness checks)
In conclusion, the results obtained with the main analyses are quite robust, indicating consistent cross-level interactions between insomnia and stress on HR_NREM
Here, we summarize the results obtained from the regression analyses conducted above.
First, we aimed at characterizing sleep patterns in adolescents with and without insomnia. This was done by specifying models in which s.archit, s.timing, s.variab, and s.auton variables were predicted by (1) meaningful covariates (SO.num, TotalSteps1000, weekday, and BMI), (2) insomnia, (3) participants’ sex, and (4) the interaction between sex and insomnia.
The results indicated:
no substantial relationships between insomnia and any s.archit or s.timing variable
most s.archit (i.e., TIB, TST, WASO) and s.timing (i.e., WakeUp.num) variables were negatively predicted by SO.num (whereas it positively predicted SE) and showed higher values during weekend compared to weekdays (also affecting SO.num), with boys showing shorter TIB and TST, and later SO.num than girls
deep.p and rem.p variables were only predicted by SO.num (positively associated with %deep and negatively associated with %rem sleep)
BMI negatively predicted light.p, SO.num, and WakeUp.num
some s.variab variables, namely TIB.SSD, TST.SSD, and SO.SSD were lower in insomnia than in controls, although the results for SO.SSD showed some inconsistency after the removal of participants with extreme missing data and the inclusion of covid19 as a further predictor
all s.varab variables were higher in weekend days, with some (TIB.SSD, TST.SSD) being positively predicted by BMI, and others (WASO.SSD) being negatively predicted by SO.num
both s.auton variables were substantially predicted by the interaction between insomnia and sex, with lower HR in female insomnia than female controls but not between males
in contrast, the main effect of insomnia was less substantial and consistent
both s.auton variables were positively predicted by TotalSteps1000, while HR_NREM was positively predicted by weekday.sleep and BMI, whereas HR_REM was positively precited by SO.num
Conclusion:
Overall, our results do not support a distinction between insomnia and controls in terms of objective sleep parameters, with the exception of some distinctions in terms of night-to-night variability.
Here, we visualize representative examples of the most substantial and consistent results.
predictors <- c("TotalSteps1000","weekday.sleep","BMI","insomnia")
dat <- ema
dat$insomnia <- as.factor(gsub("1","Insomnia",gsub("0","Controls",dat$insomnia)))
dat$sex <- factor(gsub("M","Boys",gsub("F","Girls",dat$sex)),levels=c("Girls","Boys"))
library(gridExtra)
p <- grid.arrange(glmerAn(long=dat,wide=demos,resp="TST.SSDc",fix.eff=c("SO.num",predictors),modelType="GLMER",
mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors="BMI",ran.eff="(1|ID)",family="gamma",link="log",
outputs="plotEff",plot.model="insomnia",plot.pred="insomnia",messages=FALSE,return.plot=TRUE,
dot.size=3,dodge=1.3) + ggtitle("") + labs(x="",y=expression(TST~SSD~(min^2))),
glmerAn(long=dat,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,modelType="GLMER",family="gamma",link="log",
mc.predictors=c("TotalSteps1000"),gmc.predictors="BMI",ran.eff="(1|ID)",
outputs="plotEff",plot.model="insomnia",plot.pred="insomnia",messages=FALSE,return.plot=TRUE,
dot.size=3,dodge=1.3) + ggtitle("") + labs(x="",y=expression(SO~SSD~(hours^2))),
glmerAn(long=dat,wide=demos,resp="HR_NREM",fix.eff=c("SO.num",predictors,"sex","sex:insomnia"),modelType="GLMER",
mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors="BMI",ran.eff="(1|ID)",
outputs="plotEff",plot.model="sex:insomnia",plot.pred="sex:insomnia",messages=FALSE,return.plot=TRUE,
dot.size=3,dodge=0.5) + ggtitle("") + labs(x="",y=expression(NREM~HR~(bpm))) +
theme(legend.title=element_blank(),legend.position=c(0.65,0.85),
legend.direction = "horizontal"),
glmerAn(long=dat,wide=demos,resp="HR_REM",fix.eff=c("SO.num",predictors,"sex","sex:insomnia"),modelType="GLMER",
mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors="BMI",ran.eff="(1|ID)",
outputs="plotEff",plot.model="sex:insomnia",plot.pred="sex:insomnia",messages=FALSE,return.plot=TRUE,
dot.size=3,dodge=0.5) + ggtitle("") + labs(x="",y=expression(REM~HR~(bpm))) +
theme(legend.title=element_blank(),legend.position=c(0.65,0.85),
legend.direction = "horizontal"),nrow=2)
ggsave(filename="RESULTS/Figure3.tiff",plot=p,dpi=500) # saving figure for the manuscript
Second, we aimed at characterizing the patterns of stress, worry, and mood among adolescents with and without insomnia. This was done by specifying models predicting diary ratings by (1) meaningful covariates (TotalSteps1000 and weekday), (2) the insomnia group, (3) participants’ sex, and (4) the interaction between sex and insomnia groups.
The results indicated:
no substantial relationships between insomnia and any diary rating
however, a better examination of the three insomnia.group subgroups revealed a main effect of insomnia, with higher stress, worry, and fs in the DSM.insomnia group compared to the control group, and no difference between the partial DSM and the control group; such subgroup differences were consistent across all robustness checks
in addition, lower stress, worry, and bad mood were predicted by weekend days, whereas higher-than-usual TotalSteps1000 predicted lower stress and bad mood
Conclusion:
Overall, our results consistently showed higher stress, worry, and fs in the full DSM.insomnia subgroup compared to the control group, but no differences when the two subgroup are joined
Third, we aimed at evaluating the direct and bidirectional relationship between sleep and psychological distress, and the interaction between the latter and insomnia. This was done by specifying models predicting s.archit, s.timing, s.variab, and s.auton variables measured at day i by the selected model in step 1 in addition to (1) PsyDist measured at day i, and (2) PsyDist measured at day i+1, as well as (3) the interaction between PsyDist and insomnia.
The results indicated:
substantial negative relationships were between some sleep.archit and sleep.timing variables (i.e., TIB, TST, and WakeUp.num) and stress, worry, and PsyDist, whereas earlier SO.num was substantially predicted by worry and mood, and shorter WASO was only predicted by previous day worry and PsyDist
a positive relationship was also found between previous day stress ratings and HR_REM
in contrast, no substantial relationships were found between previous diary ratings and both sleep stages and s.variab outcomes
overall, the results obtained for previous day single item ratings were consistent with those found for aggregate ratings, and across the robustness checks, with the exception of the relationships found for mood (insubstantial in 2 to 3 out of 4 robustness checks) and that found between worry and SO (insubstantial in 2 out of 4 checks)
Here, we generate the outputs of representative examples of sleep outcomes only predicted by previous day ratings, that is the models predicting TIB, TST, and WakeUp.num by worry.
# preparing data
dat <- ema[!is.na(ema$TIB) & !is.na(ema$worry),] # removing incomplete cases
demos$SO.num.cm <- summarySE(dat,measurevar="SO.num",groupvars="ID",na.rm=TRUE)[,3] # worry & SO individual means
demos$worry.cm <- summarySE(dat,measurevar="worry",groupvars="ID",na.rm=TRUE)[,3]
demos$BMI.gmc <- demos$BMI - mean(demos$BMI) # grand-mean centering BMI
dat <- plyr::join(dat,demos[,c("ID","worry.cm","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat$SO.num.mc <- dat$SO.num - dat$SO.num.cm # mean-centering worry & SO
dat$worry.mc <- dat$worry - dat$worry.cm
# modeling
fit1 <- lmer(TIB ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID),data=dat,REML=FALSE) # TIB by worry
fit2 <- lmer(TST ~ SO.num.mc + weekday.sleep + worry.mc + (worry.mc|ID),data=dat,REML=FALSE) # TST by worry
fit3 <- lmer(WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + (worry.mc|ID),data=dat,REML=FALSE) # WakeUp.num by worry
# showing models
tab_model(fit1,fit2,fit3,
show.p=FALSE,show.stat=FALSE,show.icc=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
string.est="B (SE)")
| TIB | TST | Wake Up num | ||||
|---|---|---|---|---|---|---|
| Predictors | B (SE) | CI | B (SE) | CI | B (SE) | CI |
| (Intercept) |
451.42 (4.45) |
442.69 – 460.14 |
398.96 (3.80) |
391.52 – 406.40 |
8.00 (0.09) |
7.82 – 8.18 |
| SO.num.mc |
-35.38 (0.91) |
-37.17 – -33.59 |
-30.29 (0.82) |
-31.89 – -28.69 |
0.40 (0.02) |
0.37 – 0.43 |
| weekday.sleep [weekend] |
48.99 (2.38) |
44.32 – 53.66 |
43.49 (2.13) |
39.33 – 47.66 |
0.83 (0.04) |
0.75 – 0.91 |
| worry.mc |
-8.12 (1.61) |
-11.29 – -4.96 |
-7.25 (1.47) |
-10.13 – -4.37 |
-0.13 (0.03) |
-0.18 – -0.08 |
| SD (Intercept) |
40.94 (NA) |
34.77 (NA) |
0.88 (NA) |
|||
| SD (worry.mc) |
9.76 (NA) |
9.08 (NA) |
0.17 (NA) |
|||
| Cor (Intercept~ID) |
0.26 (NA) |
0.20 (NA) |
-0.44 (NA) |
|||
| SD (Observations) |
8.23 (NA) |
7.78 (NA) |
1.06 (NA) |
|||
| BMI.gmc |
-0.11 (0.03) |
-0.17 – -0.06 | ||||
| Random Effects | ||||||
| σ2 | 4596.27 | 3658.59 | 1.29 | |||
| τ00 | 1676.43 ID | 1208.86 ID | 0.77 ID | |||
| τ11 | 95.32 ID.worry.mc | 82.37 ID.worry.mc | 0.03 ID.worry.mc | |||
| ρ01 | 0.26 ID | 0.20 ID | -0.44 ID | |||
| N | 93 ID | 93 ID | 93 ID | |||
| Observations | 4333 | 4333 | 4333 | |||
# computing profile-likelihood CI
confint.merMod(fit1,method="profile")
## 2.5 % 97.5 %
## .sig01 35.27068935 48.0912036
## .sig02 -0.07862508 0.5705205
## .sig03 6.49279498 13.3520713
## .sigma 66.36381360 69.2798607
## (Intercept) 442.59400293 460.2197769
## SO.num.mc -37.17534165 -33.5916031
## weekday.sleepweekend 44.31328548 53.6634936
## worry.mc -11.33458738 -4.9313513
confint.merMod(fit2,method="profile")
## 2.5 % 97.5 %
## .sig01 29.9059976 40.8910792
## .sig02 -0.1256392 0.5061278
## .sig03 6.1589119 12.3029964
## .sigma 59.2085317 61.8105382
## (Intercept) 391.4276495 406.4619905
## SO.num.mc -31.8871982 -28.6884596
## weekday.sleepweekend 39.3229845 47.6670351
## worry.mc -10.1717877 -4.3451670
confint.merMod(fit3,method="profile")
## 2.5 % 97.5 %
## .sig01 0.7579527 1.03278974
## .sig02 -0.7069307 -0.09320865
## .sig03 0.1170681 0.23567037
## .sigma 1.1100121 1.15879514
## (Intercept) 7.8134926 8.18576085
## SO.num.mc 0.3747804 0.43473015
## weekday.sleepweekend 0.7504104 0.90680074
## BMI.gmc -0.1714414 -0.05736955
## worry.mc -0.1849123 -0.07525435
The results indicated:
some s.archit and s.timing variables (i.e., TIB, TST, and WakeUp.num) were bidirectionally associated with stress, with higher-than-usual previous day and next day stress predicting shorter TIB and TST, and earlier WakeUp time
WASO was only (negatively) related to next day stress but not to previous day stress; similarly, HR_NREM and HR_REM were positively associated with next day mood but not with previous day mood
WakeUp.num.SSD was negatively associated with all next day diary ratings, whereas relationships between next day ratings and other s.variab outcomes were less consistent
overall, these results were consistent across the robustness checks but not replicated by the aggregate diary ratings
The results indicated:
a substantial interaction between insomnnia and previous day ratings was only found for stress on HR_NREM, such that stress predicted higher HR_NREM in the insomnia but not the control group; this result was overall consistent across the robustness checks, becoming not substantial only when considering the insomnia.group
a similar but less consistent result was found for worry and fs
none of the other diary ratings and sleep outcomes showed substantial interactions, consistently across the robustness checks
Here, we generate the outputs of representative examples of sleep outcomes predicted by the next day and the interactive term, that is the models predicting TST, WakeUp.num and HR_NREM by stress.
# preparing data
dat1 <- ema[!is.na(ema$TST) & !is.na(ema$stress) & !is.na(ema$s.nd),] # removing incomplete cases
datwide <- summarySE(dat1,measurevar="stress",groupvars="ID",na.rm=TRUE)[,c(1,3)] # ind means
colnames(datwide)[2] <- "stress.cm"
datwide$s.nd.cm <- summarySE(dat1,measurevar="s.nd",groupvars="ID",na.rm=TRUE)[,3] # individual means
datwide <- plyr::join(datwide,demos[,c("ID","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat1 <- plyr::join(dat1,datwide[,c("ID","stress.cm","s.nd.cm","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat1$SO.num.mc <- dat1$SO.num - dat1$SO.num.cm # mean-centering SO and stress
dat1$stress.mc <- dat1$stress - dat1$stress.cm
dat1$s.nd.mc <- dat1$s.nd - dat1$s.nd.cm
# same operation for HR_NREM
dat2 <- ema[!is.na(ema$HR_NREM) & !is.na(ema$stress) & !is.na(ema$s.nd) & !is.na(ema$TotalSteps1000),]
datwide <- datwide[datwide$ID%in%dat2$ID,]
datwide$TotalSteps1000.cm <- summarySE(dat2,measurevar="TotalSteps1000",groupvars="ID",na.rm=TRUE)[,3]
dat2 <- plyr::join(dat2,datwide[,c("ID","stress.cm","s.nd.cm","SO.num.cm","TotalSteps1000.cm","BMI.gmc")],
by="ID",type="left")
dat2$SO.num.mc <- dat2$SO.num - dat2$SO.num.cm # mean-centering SO and stress
dat2$TotalSteps1000.mc <- dat2$TotalSteps1000 - dat2$TotalSteps1000.cm
dat2$stress.mc <- dat2$stress - dat2$stress.cm
dat2$s.nd.mc <- dat2$s.nd - dat2$s.nd.cm
# modeling
fit1 <- lmer(TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (stress.mc|ID), # TST
data=dat1,REML=FALSE)
fit2 <- lmer(WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (stress.mc|ID), # WakeUp.num
data=dat1,REML=FALSE)
fit3 <- lmer(HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + insomnia + # HR_NREM
stress.mc + s.nd.mc + stress.mc:insomnia + (stress.mc|ID),
data=dat2,REML=FALSE)
# showing models
tab_model(fit1,fit2,fit3,
show.p=FALSE,show.stat=FALSE,show.icc=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
string.est="B (SE)")
| TST | Wake Up num | HR NREM | ||||
|---|---|---|---|---|---|---|
| Predictors | B (SE) | CI | B (SE) | CI | B (SE) | CI |
| (Intercept) |
399.53 (3.85) |
391.99 – 407.07 |
8.03 (0.09) |
7.86 – 8.21 |
63.13 (1.04) |
61.10 – 65.17 |
| SO.num.mc |
-32.12 (0.89) |
-33.85 – -30.38 |
0.37 (0.02) |
0.34 – 0.41 | ||
| weekday.sleep [weekend] |
45.87 (2.26) |
41.44 – 50.29 |
0.86 (0.04) |
0.78 – 0.94 |
0.38 (0.17) |
0.04 – 0.71 |
| stress.mc |
-5.22 (1.34) |
-7.86 – -2.59 |
-0.10 (0.03) |
-0.15 – -0.05 |
-0.01 (0.14) |
-0.28 – 0.26 |
| s.nd.mc |
-6.40 (1.11) |
-8.57 – -4.22 |
-0.12 (0.02) |
-0.16 – -0.08 |
-0.04 (0.08) |
-0.21 – 0.12 |
| SD (Intercept) |
34.75 (NA) |
0.84 (NA) |
5.96 (NA) |
|||
| SD (stress.mc) |
6.65 (NA) |
0.13 (NA) |
0.42 (NA) |
|||
| Cor (Intercept~ID) |
0.40 (NA) |
-0.74 (NA) |
0.32 (NA) |
|||
| SD (Observations) |
7.73 (NA) |
1.06 (NA) |
1.95 (NA) |
|||
| BMI.gmc |
-0.10 (0.03) |
-0.15 – -0.05 |
0.45 (0.20) |
0.07 – 0.84 | ||
| TotalSteps1000.mc |
0.16 (0.02) |
0.12 – 0.19 | ||||
| sex [M] |
-4.37 (1.33) |
-6.98 – -1.77 | ||||
| insomnia [1] |
-3.08 (1.29) |
-5.61 – -0.54 | ||||
| insomnia [1] * stress.mc |
0.38 (0.19) |
0.00 – 0.75 | ||||
| Random Effects | ||||||
| σ2 | 3566.96 | 1.24 | 14.58 | |||
| τ00 | 1207.52 ID | 0.71 ID | 35.49 ID | |||
| τ11 | 44.22 ID.stress.mc | 0.02 ID.stress.mc | 0.18 ID.stress.mc | |||
| ρ01 | 0.40 ID | -0.74 ID | 0.32 ID | |||
| N | 92 ID | 92 ID | 90 ID | |||
| Observations | 3798 | 3798 | 2773 | |||
# computing profile-likelihood CI
confint.merMod(fit1,method="profile")
## 2.5 % 97.5 %
## .sig01 29.7838247 41.005272
## .sig02 -0.0136352 1.000000
## .sig03 2.2020238 10.431355
## .sigma 58.3701847 61.130986
## (Intercept) 391.8898179 407.127134
## SO.num.mc -33.8535435 -30.380119
## weekday.sleepweekend 41.4377016 50.294074
## stress.mc -8.0069022 -2.584715
## s.nd.mc -8.5707792 -4.219271
confint.merMod(fit2,method="profile")
## 2.5 % 97.5 %
## .sig01 0.7221278 0.99075720
## .sig02 -1.0000000 -0.37607133
## .sig03 0.0647134 0.20365889
## .sigma 1.0889721 1.14048602
## (Intercept) 7.8542339 8.21497023
## SO.num.mc 0.3417267 0.40639117
## weekday.sleepweekend 0.7795405 0.94463056
## BMI.gmc -0.1480120 -0.04578552
## stress.mc -0.1557031 -0.05296821
## s.nd.mc -0.1608079 -0.07971410
confint.merMod(fit3,method="profile")
## 2.5 % 97.5 %
## .sig01 5.164229866 6.9660122
## .sig02 -0.151009897 0.9340383
## .sig03 0.135192465 0.6657999
## .sigma 3.717090978 3.9239849
## (Intercept) 61.073403407 65.1885299
## TotalSteps1000.mc 0.116272260 0.1943926
## weekday.sleepweekend 0.042457748 0.7094334
## BMI.gmc 0.062519532 0.8465953
## sexM -7.003550009 -1.7395305
## insomnia1 -5.638113937 -0.5138422
## stress.mc -0.280379557 0.2658698
## s.nd.mc -0.208040175 0.1212669
## insomnia1:stress.mc -0.001953441 0.7579268
Cranford, J. A., Shrout, P. E., Iida, M., Rafaeli, E., Yip, T., & Bolger, N. (2006). A Procedure for Evaluating Sensitivity to Within-Person Change: Can Mood Measures in Diary Studies Detect Change Reliably? Personality and Social Psychology Bulletin, 32(7), 917–929. https://doi.org/10.1177/0146167206287721
Geldhof, G. J., Preacher, K. J., & Zyphur, M. J. (2014). Reliability estimation in a multilevel confirmatory factor analysis framework. Psychological Methods, 19(1), 72–91. https://doi.org/10.1037/a0032138
Green, J. A. (2021). Too many zeros and/or highly skewed? A tutorial on modelling health behaviour as count data with Poisson and negative binomial regression. Health Psychology and Behavioral Medicine, 9(1), 436-455. https://doi.org/10.1080/21642850.2021.1920416
Hox, J. J. (2010). Multilevel Analysis: Techniques and Applications (2nd ed.). Routledge.
Jak, S., & Jorgensen, T. D. (2017). Relating Measurement Invariance, Cross-Level Invariance, and Multilevel Reliability. Frontiers in Psychology, 8(OCT), 1–9. https://doi.org/10.3389/fpsyg.2017.01640
Menghini, L., Yuksel, D., Goldstone, A., Baker, F. C., & de Zambotti, M. (2021). Performance of Fitbit Charge 3 against polysomnography in measuring sleep in adolescent boys and girls. Chronobiology International, 38(7):1010-1022. https://doi.org/10.1080/07420528.2021.1903481
Ng, V. K., & Cribbie, R. A. (2017). Using the gamma generalized linear model for modeling continuous, skewed and heteroscedastic outcomes in psychology. Current Psychology, 36(2), 225-235. https://doi.org/10.1007/s12144-015-9404-0